routing-tanstack-router
File-based routing conventions with TanStack Router — route files, search param validation, loaders, and error boundaries.
SKILL.md.claude/skills/routing-tanstack-router/SKILL.md
GitHub- Routes are files under
src/routes/;src/routes/__root.tsxis the shared layout (createRootRoute, renders<Outlet />). A new top-level page issrc/routes/<name>.tsxusingcreateFileRoute("/<name>")({ component }). - The route tree (
src/routeTree.gen.ts) is generated by the@tanstack/router-pluginVite plugin on everydev/buildrun — never hand-edit it. It is committed to the repo (not gitignored) so a fresh clone type-checks before the firstvite buildregenerates it. - Search params: validate with a Standard-Schema-compatible library (Zod ≥3.24 or Arktype) —
no adapter package needed, TanStack Router reads the schema directly via
validateSearch. Never readlocation.searchmanually. - Data fetching belongs in TanStack Query hooks (
server-state-tanstack-queryskill) called from the route's component, not in a routerloader, unless the data must block navigation (e.g., an auth guard) — preferuseSuspenseQuery+ a<Suspense>boundary in the component for everything else, matchingsrc/routes/index.tsx. - Every route component needs an
aria-labelledby'd landmark and an<h1>matching the page purpose (seesrc/routes/index.tsx,about.tsx) — a11y-auditor checks this on route-level scans.