Back to Router

TanStack Router — Skill Spec

_artifacts/skill_spec.md

1.166.718.1 KB
Original Source

TanStack Router — Skill Spec

TanStack Router is a type-safe router for React and Solid applications with built-in SWR caching, JSON-first search params, file-based route generation, and end-to-end type inference. It is client-first/isomorphic — loaders run on the client by default and additionally on the server when used with TanStack Start.

Domains

DomainDescriptionSkills
Defining RoutesSetting up route trees, configuring the router, registering typesroute-setup, migrate-from-react-router
NavigatingLinks, imperative navigation, preloading, blockingnavigation
Managing URL StateSearch params and path params with validation and serializationsearch-params, path-params
Loading DataRoute loaders, SWR caching, external cache coordination, context/DIdata-loading, external-data-loading
Protecting RoutesAuth guards, RBAC, beforeLoad redirectsauth-and-guards
Rendering and LayoutCode splitting, error/not-found handling, route maskingcode-splitting, not-found-and-errors, route-masking
Type SafetyInference patterns, narrowing, TS performancetype-safety
Server-Side RenderingSSR setup, hydration, head managementssr

Skill Inventory

SkillTypeDomainWhat it coversFailure modes
route-setupcoredefining-routescreateRouter, file/code/virtual routing, Register, plugin config, ESLint5
navigationcorenavigatingLink, useNavigate, Navigate, preloading, blocking, active states, scroll restoration4
search-paramscoremanaging-url-statevalidateSearch, useSearch, middlewares, serialization, adapters4
path-paramscoremanaging-url-state$params, splats, optional params, prefix/suffix patterns3
data-loadingcoreloading-dataloader, loaderDeps, staleTime/gcTime, pending/error, context/DI, deferred5
external-data-loadingcompositionloading-dataTanStack Query integration, SSR dehydration/hydration, streaming3
auth-and-guardscoreprotecting-routesbeforeLoad redirects, layout auth, RBAC, provider integration3
code-splittingcorerendering-and-layoutautoCodeSplitting, .lazy.tsx, getRouteApi, split groupings4
not-found-and-errorscorerendering-and-layoutnotFound(), notFoundComponent, errorComponent, CatchBoundary3
route-maskingcorerendering-and-layoutmask option, createRouteMask, unmaskOnReload1
type-safetycoretype-safetyRegister, from narrowing, TS perf, type utilities3
ssrcoreserver-side-renderingRouterClient/Server, streaming, hydration, head management3
migrate-from-react-routerlifecycledefining-routesMigration checklist, API mapping, search params conversion2

Failure Mode Inventory

route-setup (5 failure modes)

#MistakePrioritySourceCross-skill?
1Missing router type registrationCRITICALdocs/guide/creating-a-routertype-safety
2Not committing routeTree.gen.tsHIGHdocs/faq
3Wrong route property order breaks type inferenceHIGHdocs/eslint/create-route-property-order
4Placing TanStackRouter plugin after framework pluginHIGHdocs/installation/with-vite
5Using getParentRoute incorrectly in code-based routingHIGHdocs/decisions-on-dx
#MistakePrioritySourceCross-skill?
1Interpolating params into the to stringCRITICALdocs/guide/navigationtype-safety
2Using useNavigate instead of Link for clickable elementsMEDIUMdocs/guide/navigation
3Not providing from for relative navigationHIGHdocs/guide/navigation
4Using search as object instead of function loses paramsHIGHdocs/how-to/navigate-with-search-paramssearch-params

search-params (4 failure modes)

#MistakePrioritySourceCross-skill?
1Using zod .catch() instead of adapter fallback()HIGHdocs/guide/search-params
2Returning entire search object from loaderDepsHIGHdocs/guide/data-loadingdata-loading
3Passing Date objects in search paramsHIGHdocs/how-to/arrays-objects-dates
4Parent route missing validateSearch blocks inheritanceMEDIUMdocs/how-to/share-search-params

path-params (3 failure modes)

#MistakePrioritySourceCross-skill?
1Interpolating path params into to stringCRITICALdocs/guide/navigationnavigation
2Using * for splat routes instead of $MEDIUMdocs/routing/routing-concepts
3Using curly braces for basic dynamic segmentsMEDIUMdocs/guide/path-params

data-loading (5 failure modes)

#MistakePrioritySourceCross-skill?
1Assuming loaders only run on the serverCRITICALmaintainer interviewssr
2Not understanding staleTime default is 0MEDIUMdocs/guide/data-loading
3Using reset() instead of router.invalidate() in error componentsHIGHdocs/guide/data-loading
4Double parentheses missing on createRootRouteWithContextHIGHdocs/guide/data-loading
5Using React hooks in beforeLoad or loaderHIGHdocs/guide/router-context

external-data-loading (3 failure modes)

#MistakePrioritySourceCross-skill?
1Not setting defaultPreloadStaleTime to 0HIGHdocs/guide/external-data-loading
2Creating QueryClient outside createRouter for SSRHIGHdocs/guide/external-data-loading
3Awaiting prefetchQuery in loader blocks renderingMEDIUMdocs/integrations/query

auth-and-guards (3 failure modes)

#MistakePrioritySourceCross-skill?
1Auth check in component instead of beforeLoadHIGHdocs/how-to/setup-authentication
2Not re-throwing redirects in try/catchHIGHdocs/guide/authenticated-routes
3Trying to conditionally render root route componentMEDIUMdocs/faq

code-splitting (4 failure modes)

#MistakePrioritySourceCross-skill?
1Exporting route property functions prevents code splittingHIGHdocs/guide/automatic-code-splitting
2Trying to code-split the root routeMEDIUMdocs/guide/code-splitting
3Splitting the loader adds double async costMEDIUMdocs/guide/code-splitting
4Importing Route in code-split files for typed hooksHIGHdocs/guide/code-splitting

not-found-and-errors (3 failure modes)

#MistakePrioritySourceCross-skill?
1Using deprecated NotFoundRouteHIGHdocs/guide/not-found-errors
2Expecting useLoaderData to work in notFoundComponentMEDIUMdocs/guide/not-found-errors
3Leaf route cannot handle not-found errorsMEDIUMdocs/guide/not-found-errors

route-masking (1 failure mode)

#MistakePrioritySourceCross-skill?
1Expecting masked URLs to survive sharingMEDIUMdocs/guide/route-masking

type-safety (3 failure modes)

#MistakePrioritySourceCross-skill?
1Adding type annotations or casts to inferred valuesCRITICALmaintainer interview
2Using un-narrowed LinkProps typeHIGHdocs/guide/type-safety
3Not narrowing Link/useNavigate with fromHIGHdocs/guide/type-safety

ssr (3 failure modes)

#MistakePrioritySourceCross-skill?
1Using browser APIs in loaders without environment checkHIGHdocs/guide/ssrdata-loading
2Using hash fragments for server-rendered contentMEDIUMdocs/guide/navigation
3Generating Next.js or Remix SSR patternsCRITICALmaintainer interviewroute-setup, data-loading

migrate-from-react-router (2 failure modes)

#MistakePrioritySourceCross-skill?
1Leaving React Router imports alongside TanStack RouterHIGHdocs/how-to/migrate-from-react-router
2Using React Router useSearchParams patternHIGHdocs/installation/migrate-from-react-router

Tensions

TensionSkillsAgent implication
Type safety strictness vs rapid prototypingtype-safety ↔ route-setupAgents skip Register declaration or use type casts to silence errors
Client-first loaders vs SSR expectationsdata-loading ↔ ssrAgents put server-only code in client loaders or avoid browser APIs unnecessarily
Built-in SWR cache vs external cache coordinationdata-loading ↔ external-data-loadingAgents use both caches simultaneously causing stale data or double-fetching
Code splitting granularity vs loader performancecode-splitting ↔ data-loadingAgents split everything including loaders, adding latency

Cross-References

FromToReason
route-setuptype-safetyRegister declaration and property order are prerequisites for type inference
navigationsearch-paramsLink search prop directly interacts with search param validation
data-loadingsearch-paramsloaderDeps consumes validated search params as cache keys
data-loadingexternal-data-loadingUnderstanding built-in caching is prerequisite for external cache coordination
auth-and-guardsdata-loadingbeforeLoad runs before loader — auth context flows into loader via route context
code-splittingdata-loadingLoader splitting decisions affect data loading performance
ssrdata-loadingSSR changes where loaders execute — must handle both environments
ssrexternal-data-loadingSSR dehydration/hydration requires special Query setup
not-found-and-errorsdata-loadingnotFound() in loaders interacts with error boundaries and loader data availability
migrate-from-react-routerroute-setupMigration requires understanding TanStack Router route setup

Subsystems & Reference Candidates

SkillSubsystemsReference candidates
route-setupfile naming conventions (>10 distinct conventions)
search-paramsZod adapter, Valibot adapter, ArkType adaptersearch param validation patterns (>10 distinct patterns)
All others
  • Core skills: route-setup, navigation, search-params, path-params, data-loading, code-splitting, not-found-and-errors, route-masking, type-safety, ssr, auth-and-guards
  • Framework skills: None needed separately — React and Solid share the same core API surface. Framework-specific notes belong inline.
  • Lifecycle skills: migrate-from-react-router
  • Composition skills: external-data-loading (TanStack Query)
  • Reference files: search-params (validation patterns), route-setup (file naming conventions)

Composition Opportunities

LibraryIntegration pointsComposition skill needed?
@tanstack/react-queryLoader coordination, SSR dehydration/hydration, streamingYes — external-data-loading
ZodSearch param validationNo — covered as subsystem in search-params
ValibotSearch param validationNo — covered as subsystem in search-params
ArkTypeSearch param validationNo — covered as subsystem in search-params