TanStack Router file-based routing Cursor rules
This Cursor rule file covers TanStack Router v1 in React apps, with file-based routing, typed params, validated search params, loaders, auth guards and route preloading. It is for TypeScript developers who want routing that is fully type-safe from the URL to the component.
What it does
Routes are defined with createFileRoute or createRootRoute, never plain objects. Data loads in loader functions, not useEffect. Search params get a Zod or Valibot schema. Setup uses @tanstack/react-router with Vite and @tanstack/router-vite-plugin, routes under src/routes/ with __root.tsx as the layout, and a generated routeTree.gen.ts that is never edited by hand.
How to use it
The globs are **/*.
Requirements and limits
Code-based routing is reserved for highly dynamic cases.
More in Rules and the Cursor library.
What it covers
- Core Philosophy
- Project Setup
- File-Based Route Conventions
- Route Definition Patterns
- Type-Safe Search Params
- Navigation
- Loaders & Data Fetching
- Error Handling
- Router Context
- Route Guards / Auth
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.