npm-packages/docs/docs/quickstart/tanstack-start.mdx
import sampleData from "!!raw-loader!@site/../private-demos/quickstarts/tanstack-start/sampleData.jsonl"; import appRoutesRoot from "!!raw-loader!@site/../private-demos/quickstarts/tanstack-start/src/routes/__root.tsx"; import router from "!!raw-loader!@site/../private-demos/quickstarts/tanstack-start/src/router.tsx"; import index from "!!raw-loader!@site/../private-demos/quickstarts/tanstack-start/src/routes/index.tsx"; import tasks from "!!raw-loader!@site/../private-demos/quickstarts/tanstack-start/convex/tasks.ts";
<Admonition type="caution" title="TanStack Start is in Release Candidate">TanStack Start is a new React framework currently in the Release Candidate stage. You can try it today but there might still be bug or issues.
</Admonition>To get setup quickly with Convex and TanStack Start run
<p> <b> <CodeWithCopyButton text="npm create convex@latest -- -t tanstack-start" /> </b> </p>or follow the guide below.
To use Clerk with Convex and TanStack Start, see the TanStack Start + Clerk guide
Learn how to query data from Convex in a TanStack Start site.
<StepByStep> <Step title="Create a TanStack Start site">Create a TanStack Start app using the create-start-app command:
```sh
npx create-start-app@latest
```
```sh
npm install convex @convex-dev/react-query @tanstack/react-router-with-query @tanstack/react-query
```
<Snippet
source={appRoutesRoot}
title="app/routes/__root.tsx"
highlightPatterns={[ "createRootRouteWithContext", "QueryClient", "\\}\\>\\(\\)\\(\\{"]}
/>
This creates a `ConvexClient` and a `ConvexQueryClient` and wires in a `ConvexProvider`.
<Snippet
source={router}
title="app/router.tsx"
/>
It will also create a `convex/` folder for you
to write your backend API functions in. The `dev` command
will then continue running to sync your functions
with your dev deployment in the cloud.
```sh
npx convex dev
```
<Snippet
source={sampleData}
title="sampleData.jsonl"
/>
```
npx convex import --table tasks sampleData.jsonl
```
Exporting a query function from this file
declares an API function named after the file
and the export name, `api.tasks.get`.
<Snippet
source={tasks}
title="convex/tasks.ts"
/>
The `useSuspenseQuery` hook renders the API function `api.tasks.get`
query result on the server initially, then it updates live in the browser.
<Snippet
source={index}
title="app/routes/index.tsx"
highlightPatterns={[ "useSuspenseQuery" ]}
/>
```sh
npm run dev
```
For more see the TanStack Start with Convex client documentation page.