TanStack Router type-safe file-based routing for React. Use for SPAs, TanStack Query integration, Cloudflare Workers, or encountering devtools, type safety, loader, Vite bundling errors.
npx skills add https://github.com/secondsky/claude-skills --skill tanstack-router
Build type-safe, file-based routing for React SPAs with TanStack Router, optimized for Cloudflare Workers deployment.
Auto-triggers when you mention:
Use this skill when:
bun add @tanstack/react-router @tanstack/router-devtools
bun add -d @tanstack/router-plugin
Latest version: v1.134.13 (verified 2025-11-07)
// vite.config.ts
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import { TanStackRouterVite } from '@tanstack/router-plugin/vite'
export default defineConfig({
plugins: [
TanStackRouterVite(), // MUST come before react()
react(),
],
})
// src/routes/__root.tsx
import { createRootRoute, Outlet } from '@tanstack/react-router'
export const Route = createRootRoute({
component: () => (
<div>
<nav>
<Link to="/">Home</Link>
<Link to="/about">About</Link>
</nav>
<hr />
<Outlet />
</div>
),
})
// src/routes/index.tsx
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/')({
component: () => <h1>Home Page</h1>,
})
// src/routes/about.tsx
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/about')({
component: () => <h1>About Page</h1>,
})
// src/main.tsx
import { createRouter, RouterProvider } from '@tanstack/react-router'
import { routeTree } from './routeTree.gen' // Auto-generated
const router = createRouter({ routeTree })
function App() {
return <RouterProvider router={router} />
}
// Fully typed!
<Link to="/posts/$postId" params={{ postId: '123' }} />
// TypeScript error if route doesn't exist
<Link to="/invalid-route" /> // ❌ Error!
// src/routes/posts.$postId.tsx
export const Route = createFileRoute('/posts/$postId')({
loader: async ({ params }) => {
const post = await fetchPost(params.postId) // Fully typed!
return { post }
},
component: ({ useLoaderData }) => {
const { post } = useLoaderData()
return <h1>{post.title}</h1>
},
})
import { queryOptions } from '@tanstack/react-query'
const postQueryOptions = (postId: string) =>
queryOptions({
queryKey: ['posts', postId],
queryFn: () => fetchPost(postId),
})
export const Route = createFileRoute('/posts/$postId')({
loader: ({ context: { queryClient }, params }) =>
queryClient.ensureQueryData(postQueryOptions(params.postId)),
component: () => {
const { postId } = Route.useParams()
const { data: post } = useQuery(postQueryOptions(postId))
return <h1>{post.title}</h1>
},
})
Problem: Build fails with @tanstack/router-devtools-core not found.
Solution:
bun add @tanstack/router-devtools
Problem: Routes not auto-generated.
Solution: TanStackRouterVite MUST come before react():
plugins: [
TanStackRouterVite(), // First!
react(),
]
Problem: Link to not typed.
Solution:
// src/routeTree.gen.ts is auto-generated
// Import it in main.tsx to register types
import { routeTree } from './routeTree.gen'
Problem: Loader function not called on navigation.
Solution: Ensure route exports Route:
export const Route = createFileRoute('/path')({ loader: ... })
Problem: Production crashes when using TanStack Form + Router.
Solution: This is a known issue (#5734). Workaround: Use React Hook Form instead, or wait for fix.
import { defineConfig } from 'vite'
import { TanStackRouterVite } from '@tanstack/router-plugin/vite'
import { cloudflare } from '@cloudflare/vite-plugin'
export default defineConfig({
plugins: [
TanStackRouterVite(),
react(),
cloudflare(),
],
})
// functions/api/posts.ts
export async function onRequestGet({ env }) {
const { results } = await env.DB.prepare('SELECT * FROM posts').all()
return Response.json(results)
}
// Client-side route
export const Route = createFileRoute('/posts')({
loader: async () => {
const posts = await fetch('/api/posts').then(r => r.json())
return { posts }
},
})
All templates in ~/.claude/skills/tanstack-router/templates/:
Deep-dive guides in ~/.claude/skills/tanstack-router/references/:
Works with:
Without skill: ~10k tokens, 40-50 min, 3-4 errors
With skill: ~4k tokens, 15-20 min, 0 errors
Savings: 60% tokens, 65% time
Tested with:
Stack compatibility:
Last Updated: 2025-11-07
Library Version: @tanstack/react-router v1.134.13
Run Python code in the cloud with serverless containers, GPUs, and autoscaling. Use when deploying ML models, running batch processing jobs, scheduling compute-intensive tasks, or serving APIs that require GPU acceleration or dynamic scaling.
Advanced GitHub Actions workflow automation with AI swarm coordination, intelligent CI/CD pipelines, and comprehensive repository management
Google Cloud Platform CLI - manage GCP resources including Compute Engine, Cloud Run, GKE, Cloud Functions, Storage, BigQuery, and more.
Expert backend architect specializing in scalable API design, microservices architecture, and distributed systems. Masters REST/GraphQL/gRPC APIs, event-driven architectures, service mesh patterns, and modern backend frameworks. Handles service boundary definition, inter-service communication, resilience patterns, and observability. Use PROACTIVELY when creating new backend services or APIs.
Run Python code in the cloud with serverless containers, GPUs, and autoscaling. Use when deploying ML models, running batch processing jobs, scheduling compute-intensive tasks, or serving APIs that require GPU acceleration or dynamic scaling.
Aspire skill covering the Aspire CLI, AppHost orchestration, service discovery, integrations, MCP server, VS Code extension, Dev Containers, GitHub Codespaces, templates, dashboard, and deployment. Use when the user asks to create, run, debug, configure, deploy, or troubleshoot an Aspire distributed application.
Audits Python + BigQuery pipelines for cost safety, idempotency, and production readiness. Returns a structured report with exact patch locations.
Microsoft Store Developer CLI (msstore) for publishing Windows applications to the Microsoft Store. Use when asked to configure Store credentials, list Store apps, check submission status, publish submissions, manage package flights, set up CI/CD for Store publishing, or integrate with Partner Center. Supports Windows App SDK/WinUI, UWP, .NET MAUI, Flutter, Electron, React Native, and PWA applications.
Take secondsky/tanstack-router from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.