Open History to see the last commit
1# TanStack Start - Basic React Query Example
2β
3A TanStack Start example demonstrating integration with TanStack Query (React Query).
4β
5- [TanStack Router Docs](https://tanstack.com/router)
6- [TanStack Query Docs](https://tanstack.com/query)
7β
8## Start a new project based on this example
9β
10To start a new project based on this example, run:
11β
12```sh
13npx gitpick TanStack/router/tree/main/examples/react/start-basic-react-query start-basic-react-query
14```
15β
16## Getting Started
17β
18From your terminal:
19β
20```sh
21pnpm install
22pnpm dev
23```
24β
25This starts your app in development mode, rebuilding assets on file changes.
26β
27## Build
28β
29To build the app for production:
30β
31```sh
32pnpm build
33```
34β
35## TanStack Query Integration
36β
37This example demonstrates how to use TanStack Query with TanStack Start for:
38β
39- Server-side data fetching
40- Client-side caching and synchronization
41- Confirmed server mutations followed by query invalidation
42- Explicit freshness and automatic refetching
43β
44## SSR and mutation checks
45β
46Read the [Start + TanStack Query guide](https://tanstack.com/start/latest/docs/framework/react/guide/tanstack-query). The `/preferences` page stores a harmless display name in a cookie, so its tests need no account or external API. This cookie is not authentication. The other post/user examples use JSONPlaceholder.
47β
48```sh
49pnpm exec playwright install chromium
50pnpm test:e2e
51pnpm build
52QUERY_EXAMPLE_PRODUCTION=1 pnpm test:e2e
53```
54β
55The tests check concurrent SSR request isolation, no duplicate hydration read, one refetch after mutation invalidation, and persistence on reload. Query data is fresh for 30 seconds by default in this example; choose a window appropriate for your application.