Skip to content
Source
Sign inSign up
TanStack/router
Open History to see the last commit

README.md

55 lines1.6 KB

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.