
Tanstack Router
Implement type-safe, file-based React routing with loaders, search validation, and guards while avoiding documented TanStack Router pitfalls.
Install
npx skills add https://github.com/jezweb/claude-skills --skill tanstack-routerWhat is this skill?
- Type-safe file-based routing for React with route loaders and TanStack Query integration patterns
- Documents prevention of 20 routing errors including validation structure loss, param parsing bugs, and SSR streaming cra
- Covers virtual file routes, validateSearch with Zod adapter, beforeLoad guards, and route-level error/not-found componen
- Includes troubleshooting for devtools dependency errors, Vite bundling, type safety issues, and Docker deployment on Clo
- Auto-trigger keywords map common search phrases for SPA routing and protected routes
Adoption & trust: 546 installs on skills.sh; 841 GitHub stars; 3/3 security scanners passed (skills.sh audits).
Recommended Skills
Frontend Designanthropics/skills
Vercel React Best Practicesvercel-labs/agent-skills
Remotion Best Practicesremotion-dev/skills
Vercel Composition Patternsvercel-labs/agent-skills
Develop Userscriptsxixu-me/skills
Next Best Practicesvercel-labs/next-skills
Journey fit
Primary fit
Client routing, loaders, and SPA structure are core Build work before you harden deployment and performance in Ship. Frontend is where file-based routes, TypeScript route types, and navigation UX are defined and wired to data loading.
Common Questions / FAQ
Is Tanstack Router safe to install?
skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.
SKILL.md
READMESKILL.md - Tanstack Router
{ "name": "tanstack-router", "description": "Build type-safe, file-based React routing with TanStack Router. Supports client-side navigation, route loaders, and TanStack Query integration. Prevents 20 documented errors including validation structure loss, param parsing bugs, and SSR streaming crashes. Use when implementing file-based routing patterns, building SPAs with TypeScript routing, or troubleshooting devtools dependency errors, type safety issues, Vite bundling problems, or Docker deployment issues.", "version": "1.0.0", "author": { "name": "Jeremy Dawes", "email": "jeremy@jezweb.net" }, "license": "MIT", "repository": "https://github.com/jezweb/claude-skills", "keywords": [] } # TanStack Router Skill Type-safe, file-based routing for React applications with Cloudflare Workers integration. ## Auto-Trigger Keywords ### Primary Keywords - "TanStack Router", "tanstack router", "@tanstack/react-router" - "type-safe routing", "file-based routing", "React routing TypeScript" - "route loaders", "data loading routes", "SPA routing" ### Feature Keywords - "virtual file routes", "@tanstack/virtual-file-routes", "programmatic routes" - "search params validation", "validateSearch", "@tanstack/zod-adapter" - "beforeLoad", "route guards", "authenticated routes", "protected routes" - "errorComponent", "route error boundary", "notFoundComponent" ### Integration Keywords - "Cloudflare Workers routing", "TanStack Query integration" - "route-level data fetching", "prefetch routes" ### Error Keywords - "routeTree.gen.ts missing", "route type inference not working" - "loader not running", "TanStack Form memory leak" - "virtual routes conflict", "validateSearch page reload" ## What This Provides ### 🎯 Core Features - **Type-safe navigation** - Compile-time route validation - **File-based routing** - Automatic route generation from file structure - **Virtual file routes** - Programmatic route configuration (v1.140+) - **Route loaders** - Data fetching at route level - **Search params validation** - Zod adapter with type safety - **Error boundaries** - Route-level error handling with reset - **beforeLoad guards** - Authentication without content flash - **TanStack Query integration** - Coordinate routing + data fetching - **Cloudflare Workers ready** - Deploy SPAs to Workers + Static Assets ### 📦 Templates (7) 1. package.json - Dependencies 2. vite.config.ts - Plugin setup 3. basic-routes/ - File structure example 4. route-with-loader.tsx - Data loading 5. query-integration.tsx - TanStack Query 6. nested-routes/ - Layouts 7. cloudflare-deployment.md - Workers guide ### 📚 Reference Docs (6) 1. File-based routing conventions 2. TypeScript type safety patterns 3. Data loading with loaders 4. Cloudflare Workers deployment 5. Common errors (7+) 6. Migration from React Router ## Quick Example ```typescript // src/routes/posts.$postId.tsx import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/posts/$postId')({ loader: async ({ params }) => { const post = await fetch(`/api/posts/${params.postId}`).then(r => r.json()) return { post } }, component: function Post() { const { post } = Route.useLoaderData() return <h1>{post.title}</h1> }, }) // Usage: Fully typed! <Link to="/posts/$postId" params={{ postId: '123' }} /> ``` ## 11 Errors Prevented 1. Devtools dependency resolution 2. Vite plugin ordering (CRITICAL) 3. Type registration missing 4. Loader not running 5. Memory leaks with TanStack Form (known issue #5734) 6. Middleware undefined errors 7. API route errors after restart 8. Virtual routes index/layout conflict (#5421) 9. Search params type inference regression (#3100) 10. TanStack Start validators on reload (#3711) 11. Flash of protected content (beforeLoad pattern) ## Token Efficiency | Metric | Without | With | Savings | |--------|---------|------|---------| | Tokens | 10k | 4k | **60%** | | Time | 40-50min | 15-20min | **65%** | | E