Integrate Atlas into a TanStack Start app using plain fetch or TanStack Query.
Integrate Atlas into a TanStack Start app using plain fetch or TanStack Query.
TanStack Start is a full-stack React framework. Unlike the other BYOF guides, this one does not use @ai-sdk/react -- it shows how to consume the Atlas API directly, which works with any HTTP client.
Prerequisites: A running Atlas API server. See Bring Your Own Frontend for architecture and common setup.
No AI SDK packages are required. If you prefer the useChat hook, you can install @ai-sdk/react and follow the React Vite guide -- it works the same in TanStack Start.
Tip: For a fully typed client with error handling, conversation management, and more, use the @useatlas/sdk package instead of hand-rolling fetch calls:
import { createAtlasClient } from "@useatlas/sdk";const atlas = createAtlasClient({ baseUrl: API_URL || window.location.origin, apiKey: "your-api-key",});const result = await atlas.query("How many users signed up last week?");console.log(result.answer); // narrative answerconsole.log(result.sql); // SQL queries executedconsole.log(result.data); // { columns, rows }[]console.log(result.conversationId); // for follow-up queries
If you use the @ai-sdk/reactuseChat approach, see the React/Vite guide for a complete ToolPart implementation -- it works identically in TanStack Start. The data shapes are the same across all frameworks:
executeSQL output -- { success, columns, rows, truncated } on success, or { success: false, error } on failure. Use rows.length to get the row count.
explore output -- a plain string (stdout of the command).
state -- check for "output-available" to know when the result is ready.
For the TanStack Query approach, the sync endpoint returns data in the data array directly -- no tool part parsing needed. See the Data Stream Protocol section for details on both response formats.
For most TanStack Start apps, start with the TanStack Query approach. Add @ai-sdk/react later if you need real-time streaming with tool call visualization.