TanStack Router Cursor rules with Query for React SPA
This Cursor rule file covers React single-page apps that use TanStack Router v1 for routing and TanStack Query v5 for server state. It is for teams on Vite and TypeScript who want type-safe routes and route data that is ready before render, so pages show without loading spinners.
What it does
Router owns routing and URL state, Query owns server state and caching, and components stay pure UI. Route loaders call queryClient.ensureQueryData to fill the cache before render, components read the same data with useQuery, and queryOptions factories keep keys, fetchers and staleTime in one place. Suspense handles component-level loading.
How to use it
The globs are **/*, so it applies to router setup, loaders and components.
Requirements and limits
It is written for TanStack Router v1 and Query v5.
More in Rules and the Cursor library.
What it covers
- Architecture Overview
- Project Setup
- QueryClient + Router Setup
- Query Definitions queryOptions factories
- Router Loader + Query Integration
- Search Params + Query Integration
- Mutations
- Authentication Pattern
- Prefetching on Hover
- DevTools Development Only
The full text is in the members library
Book a call and we will give you access to the full Cursor library: every entry in full, search by meaning, copy and download.
Source and license
Author: PatrickJS, Awesome cursorrules. License: CC0-1.0.