tanstack-router
✓Verified·Scanned 2/17/2026
Provides type-safe, file-based React routing with TanStack Router, including loaders, virtual routes, and Cloudflare Workers integration. Contains runtime examples that call fetch('/api/posts') and access env.DB in a Cloudflare Worker.
Scanned from main at 10a1f16 · Transparency log ↗
$ vett add jezweb/claude-skills/tanstack-router
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)
- package.json - Dependencies
- vite.config.ts - Plugin setup
- basic-routes/ - File structure example
- route-with-loader.tsx - Data loading
- query-integration.tsx - TanStack Query
- nested-routes/ - Layouts
- cloudflare-deployment.md - Workers guide
📚 Reference Docs (6)
- File-based routing conventions
- TypeScript type safety patterns
- Data loading with loaders
- Cloudflare Workers deployment
- Common errors (7+)
- Migration from React Router
Quick Example
// 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
- Devtools dependency resolution
- Vite plugin ordering (CRITICAL)
- Type registration missing
- Loader not running
- Memory leaks with TanStack Form (known issue #5734)
- Middleware undefined errors
- API route errors after restart
- Virtual routes index/layout conflict (#5421)
- Search params type inference regression (#3100)
- TanStack Start validators on reload (#3711)
- Flash of protected content (beforeLoad pattern)
Token Efficiency
| Metric | Without | With | Savings |
|---|---|---|---|
| Tokens | 10k | 4k | 60% |
| Time | 40-50min | 15-20min | 65% |
| Errors | 3-4 | 0 | 100% |
Installation
npm install @tanstack/react-router @tanstack/router-devtools
npm install -D @tanstack/router-plugin
# Optional: Search params validation
npm install @tanstack/zod-adapter zod
# Optional: Virtual file routes
npm install @tanstack/virtual-file-routes
Latest: v1.144.0
Version: 1.1.0 | Last Updated: 2026-01-03