* docs(start): add tested TanStack Query integration guide * fix(examples): protect Query server functions from cross-site calls
1.6 KiB
TanStack Start - Basic React Query Example
A TanStack Start example demonstrating integration with TanStack Query (React Query).
Start a new project based on this example
To start a new project based on this example, run:
npx gitpick TanStack/router/tree/main/examples/react/start-basic-react-query start-basic-react-query
Getting Started
From your terminal:
pnpm install
pnpm dev
This starts your app in development mode, rebuilding assets on file changes.
Build
To build the app for production:
pnpm build
TanStack Query Integration
This example demonstrates how to use TanStack Query with TanStack Start for:
- Server-side data fetching
- Client-side caching and synchronization
- Confirmed server mutations followed by query invalidation
- Explicit freshness and automatic refetching
SSR and mutation checks
Read the Start + TanStack Query guide. 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.
pnpm exec playwright install chromium
pnpm test:e2e
pnpm build
QUERY_EXAMPLE_PRODUCTION=1 pnpm test:e2e
The 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.