
router-core
Framework-agnostic core concepts for TanStack Router: route trees, createRouter, createRoute, createRootRoute, createRootRouteWithContext, addChildren, Register type declaration, route matching, route sorting, file naming conventions. Entry point for all router skills.
- Installs
- 602
- Last 24h
- +12
- Trending rank
- #8120
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/tanstack/router --skill router-core- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads router-core automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
TanStack Router Core
TanStack Router is a type-safe router for React and Solid with built-in SWR caching, JSON-first search params, file-based route generation, and end-to-end type inference. The core is framework-agnostic; React and Solid bindings layer on top.
CRITICAL: TanStack Router types are FULLY INFERRED. Never cast, never annotate inferred values. This is the #1 AI agent mistake.
CRITICAL: TanStack Router is CLIENT-FIRST. Loaders run on the client by default, NOT server-only like Remix/Next.js. Do not confuse TanStack Router APIs with Next.js or React Router.
Use this entry skill to choose one primary sub-skill. Do not load the full catalog. Load a second sub-skill only when the task crosses a real boundary, such as an authenticated loader that needs both auth-and-guards and data-loading.
Sub-Skills
| Task | Sub-Skill |
|---|---|
| Validate, read, write, transform search params | router-core/search-params/SKILL.md |
| Dynamic segments, splats, optional params | router-core/path-params/SKILL.md |
| Link, useNavigate, preloading, blocking | router-core/navigation/SKILL.md |
| Route loaders, SWR caching, context, deferred data | router-core/data-loading/SKILL.md |
| Auth guards, RBAC, beforeLoad redirects | router-core/auth-and-guards/SKILL.md |
| Automatic and manual code splitting | router-core/code-splitting/SKILL.md |
| 404 handling, error boundaries, notFound() | router-core/not-found-and-errors/SKILL.md |
| Inference, Register, from narrowing, TS perf | router-core/type-safety/SKILL.md |
| Streaming/non-streaming SSR, hydration, head mgmt | router-core/ssr/SKILL.md |
Quick Decision Tree
Need to add/read/write URL query parameters?
→ router-core/search-params
Need dynamic URL segments like /posts/$postId?
→ router-core/path-params
Need to create links or navigate programmatically?
→ router-core/navigation
Need to fetch data for a route?
Is it client-side only or client+server?
→ router-core/data-loading
Using TanStack Query as external cache?
→ compositions/router-query (separate skill)
Need to protect routes behind auth?
→ router-core/auth-and-guards
Need to reduce bundle size per route?
→ router-core/code-splitting
Need custom 404 or error handling?
→ router-core/not-found-and-errors
Having TypeScript issues or performance problems?
→ router-core/type-safety
Need server-side rendering?
→ router-core/ssr
Cross-Cutting Completion Checks
For route refactors:
- Rename or move the route file; do not hand-edit the generated
createFileRoutepath. - Regenerate
routeTree.gen.tswith the configured Router plugin or CLI. - Update links, redirects,
fromnarrowing, params, and tests that reference the old route. - Run type tests and a production build. A typecheck alone does not prove route generation or bundling works.
For response schema changes:
- Update the source model and shared validation schema.
- Update the server function or API serializer so the field exists at runtime.
- Update loader and component consumers without casts.
- Assert the actual response payload in a unit or integration test. Typechecking cannot catch a serializer that omits the new field.
Minimal Working Example
// src/routes/__root.tsx
import { createRootRoute, Outlet } from '@tanstack/react-router'
export const Route = createRootRoute({
component: () => <Outlet />,
})
// src/routes/index.tsx
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/')({
component: () => <h1>Home</h1>,
})
// src/router.tsx
import { createRouter } from '@tanstack/react-router'
import { routeTree } from './routeTree.gen'
const router = createRouter({ routeTree })
// REQUIRED for type safety — without this, Link/useNavigate have no autocomplete
declare module '@tanstack/react-router' {
interface Register {
router: typeof router
}
}
export default router
// src/main.tsx
import { RouterProvider } from '@tanstack/react-router'
import router from './router'
function App() {
return <RouterProvider router={router} />
}
Common Mistakes
HIGH: createFileRoute path string must match the file path
The Vite plugin manages the path string in createFileRoute. Do not change it manually — it must match the file's location under src/routes/:
// File: src/routes/posts/$postId.tsx
export const Route = createFileRoute('/posts/$postId')({
// ✅ matches file path
component: PostPage,
})
export const Route = createFileRoute('/post/$postId')({
// ❌ silent mismatch
component: PostPage,
})
The plugin auto-generates this string. If you rename a route file, the plugin updates it. Never edit the path string by hand.
Version Note
This skill targets @tanstack/router-core v1.171.15. Splat routes use $ (not *); the * compat alias will be removed in v2.
FAQ
What does the router-core skill do?
Framework-agnostic core concepts for TanStack Router: route trees, createRouter, createRoute, createRootRoute, createRootRouteWithContext, addChildren, Register type declaration, route matching, route sorting, file naming conventions. Entry point for all router skills.
How do I install router-core?
Run npx skills add https://github.com/tanstack/router --skill router-core in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/router-core/ (personal) or .claude/skills/router-core/ (project).
Which AI agents can use router-core?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is router-core safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains router-core?
It is published by tanstack in tanstack/router. It has 602 recorded installs.
More from tanstack/router
react-router
tanstack/router
React bindings for TanStack Router: RouterProvider, useRouter, useRouterState, useMatch, useMatches, useLocation, useSearch, useParams, useNavigate, useLoaderData, useLoaderDeps, useRouteContext, useBlocker, useCanGoBack, Link, Navigate, Outlet, CatchBoundary, ErrorComponent. React-specific patterns for hooks, providers, SSR hydration, and createLink with forwardRef.
react-start
tanstack/router
React bindings for TanStack Start: createStart, StartClient, StartServer, React-specific imports, re-exports from @tanstack/react-router, full project setup with React, useServerFn hook.
start-core
tanstack/router
Core overview for TanStack Start: tanstackStart() Vite plugin, getRouter() factory, root route document shell (HeadContent, Scripts, Outlet), client/server entry points, routeTree.gen.ts, tsconfig configuration. Entry point for all Start skills.
router-query
tanstack/router
Integrating TanStack Router with TanStack Query: queryClient in router context, static queries and fire-and-forget queries in loaders, useSuspenseQuery in components, defaultPreloadStaleTime: 0, setupRouterSsrQueryIntegration for SSR dehydration/hydration and streaming, per-request QueryClient isolation.
start-server-core
tanstack/router
Server-side runtime for TanStack Start: createStartHandler, request/response utilities (getRequest, setResponseHeader, setCookie, getCookie, appendResponseHeader), three-phase request handling, AsyncLocalStorage context.
router-plugin
tanstack/router
TanStack Router bundler plugin for route generation and automatic code splitting. Supports Vite, Webpack, Rspack, and esbuild. Configures autoCodeSplitting, routesDirectory, target framework, and code split groupings.
Popular other skills
hyperframes-cli
heygen-com/hyperframes
The HyperFrames CLI by job - scaffold, check, look at frames, edit the timeline, preview, render locally or in the cloud, publish, project history - plus reading its JSON and recovering from build or render failures.
triage
mattpocock/skills
Move issues and external PRs through a state machine of triage roles, categorise, verify, grill if needed, and write agent-ready briefs.
ask-matt
mattpocock/skills
Ask which skill or flow fits your situation. A router over the skills in this repo.
to-questionnaire
mattpocock/skills
Turn a decision you can't fully answer into a questionnaire for someone else to fill in.
loop-me
mattpocock/skills
Grill me about specs for the workflows I want to build, within this workspace.