About tanstack-router
A skill for working with TanStack Router, especially route trees, typed navigation, and route-owned data loading. It provides workflows and implementation guidance for setup, URL state, loaders, SSR, testing, and production checks.
Key features
- 01Repository and routing-mode inspection
- 02File-based route tree guidance
- 03Typed navigation and URL state patterns
- 04Loader, context, and error handling guidance
- 05SSR, testing, and production verification
Use cases
- 01Adding or changing TanStack Router routes
- 02Implementing typed search parameters and navigation
- 03Reviewing loaders, auth redirects, and error boundaries
- 04Verifying route generation and production behavior
Install
Copy the command and run it in a terminal.
$
npx skills add https:/ / github.com/ dobroslavradosavljevic/ skills --skill tanstack-routerAfter installing, type/tanstack-routerin Claude Code to confirm it loaded.
Bundled files
References and scripts installed along with SKILL.md.
agents/openai.yamlreferences/loaders-context-errors.mdnavigation-url-state.mdproduction-testing.mdsetup-route-trees.mdsource-map.mdDetails
From the project READMETanStack Router
Use this skill when work touches TanStack Router, especially @tanstack/react-router, src/routes/**, src/router.tsx, route tree generation, typed navigation, or route-owned data loading.
Workflow
- Inspect the local Router shape first:
- Package versions for
@tanstack/react-router,@tanstack/router-plugin, devtools, adapters, and any Query/SSR integration. - Routing mode: file-based, code-based, virtual file routes, or mixed.
- Route entrypoints:
src/routes/__root.tsx,src/router.tsx, generatedsrc/routeTree.gen.ts, app/client entry, and SSR entry if present. - Route options that affect behavior:
validateSearch,params,beforeLoad,loaderDeps,loader,pendingComponent,errorComponent,notFoundComponent,search.middlewares,staleTime,gcTime,preload, andssrintegration.
- Package versions for
- Refresh docs for current behavior, new versions, SSR, testing, route generation, or migrations. Start from source-map.md.
- For setup, installation, route-tree generation, file naming, and colocating non-route modules beside routes (
-components,-hooks,-lib, …), use setup-route-trees.md. - For links, navigation, params, search params, masks, and URL state, use navigation-url-state.md.
- For loaders, context, auth guards, Query integration, error/not-found boundaries, preloading, and deferred data, use loaders-context-errors.md.
- For SSR, deployment rewrites, testing, devtools, ESLint, and production checks, use production-testing.md.
Implementation Judgment
- Prefer file-based routing unless the repo already uses code-based routes or the user asks otherwise.
- Treat
routeTree.gen.tsas generated output. Do not hand-edit it; regenerate through the repo's bundler/CLI flow. - Colocate route-owned UI/hooks/helpers in hyphen-prefixed folders (
routeFileIgnorePrefix, default-). Do not leave unprefixed non-route files underroutes/. - Keep navigation typed. Do not build paths by interpolating params or query strings into
to; passto,params,search, andhashseparately. - Every route that reads URL search state should declare
validateSearch; useloaderDepsto expose only the search fields a loader actually uses. - Use
beforeLoadfor route UX gates, redirects, and context enrichment. Do not treat route guards as the private-data authorization boundary. - Put route-shared dependencies in router context; do not call React hooks directly inside
beforeLoadorloader. - Decide explicitly between Router's built-in SWR loader cache and an external cache such as TanStack Query. When Query owns freshness, set router preload stale time to
0and let Query dedupe. With Query 5.102+, load throughqueryClient.query(...);ensureQueryData/prefetchQuery/fetchQueryare deprecated. - Type
errorComponent/onCatcherrors asunknownin React and narrow before readingmessage. - Handle not-found resources in loaders with
notFound()so loader data stays correctly typed and UI avoids flicker.
Verification
Prefer the repo's existing checks. For meaningful Router changes, include the relevant subset:
- Route tree generation via dev/build or explicit Router CLI command.
- Typecheck for route references, params, search, loaders, and context.
- Focused tests for route matching, search validation, loaders, auth redirects, not-found/error boundaries, and navigation.
- Browser smoke for direct loads, client navigation, back/forward, refresh, and production rewrite behavior.
Comments
Markdown supported