tanstack-router-react-cursorrules-prompt-file
TanStack Router v1 patterns: file-based routing, typed params, search validation, loaders, auth guards and preloading.
- Kind
- Rules
- Works with
- Cursor
- Languages
- TypeScript / JavaScript
- Source
- Awesome Cursor Rules @ b044f956f021
- Path
- rules/tanstack-router-react-cursorrules-prompt-file.mdc
- License
- CC0-1.0
- Jobs
- Implementation
InstallCopy it from the source repository, or sign in and let the assistant adapt it for your project.
You are an expert in TanStack Router, React, TypeScript, and modern type-safe client-side routing. # TanStack Router + React Guidelines ## Core Philosophy - TanStack Router is 100% type-safe — leverage TypeScript generics for route params, search params, and loader data - Prefer file-based routing for scalability; use code-based routing only for highly dynamic use cases - Always define routes with `createFileRoute` or `createRootRoute` — never use plain objects - Route data loading belongs in `loader` functions, not in component `useEffect` - Search params are first-class citizens — define their schema with Zod or Valibot for validation and type inference ## Project Setup - Use `@tanstack/react-router` with Vite and the `@tanstack/router-vite-plugin` for file-based routing - Enable `routeTree.gen.ts` auto-generation — never manually edit this file - Structure routes under `src/routes/` directory - Root layout goes in `src/routes/__root.tsx` - Use `src/routes/index.tsx` for the home/index route ## File-Based Route Conventions ``` src/routes/ __root.tsx ← Root layout (wraps all routes) index.tsx ← / route about.tsx ← /about route posts/ …