Loading...
Loading...
Type-safe, file-based React routing with route loaders, search params validation, code splitting, preloading, navigation, route context, and TanStack Query integration. Use when setting up file-based routing, adding search params validation, implementing route loaders, code splitting routes, configuring virtual file routes, protecting routes with auth guards, or fixing type registration errors. Use for router setup, navigation patterns, URL state management, data loading.
npx skill4agent add oakoss/agent-skills tanstack-router@tanstack/react-router@tanstack/router-plugin| Pattern | Usage |
|---|---|
| Define file-based route |
| Root route with typed context |
| Code-split route component |
| Search params validation |
| Access loader data in component |
| Type-safe route params |
| Type-safe search params |
| Programmatic navigation |
| Block navigation (dirty forms) |
| Throw 404 from loader |
| Type-safe hooks in split files |
| Clean default values from URLs |
| Preserve params across navs |
| Method | Returns | Throws | Use Case |
|---|---|---|---|
| Data | Yes | Route loaders (recommended) |
| void | No | Background prefetching |
| Data | Yes | Immediate data need |
| Promise | No | Stream non-critical data |
| Strategy | Behavior | Use Case |
|---|---|---|
| Preload on hover/focus | Default for most links |
| Preload when Link mounts | Critical next pages |
| Preload when Link in view | Below-fold content |
| No preloading | Heavy, rarely-visited pages |
| File | Purpose |
|---|---|
| Root route with |
| Index route for |
| Dynamic param route |
| Pathless layout (auth guard) |
| Code-split component |
| Mistake | Fix |
|---|---|
| Missing router type registration | Add |
| Always pass |
| Use |
| Use |
Fetching in | Use route loaders (prevents waterfalls) |
| Sequential fetches in loader | Use |
| Missing leading slash | Always |
| TanStackRouterVite after react() | Plugin MUST come before |
| Use strict mode or manually parse after navigation |
| Pathless route notFoundComponent | Define |
| Aborted loader undefined error | Guard |
No | Declare deps so loader only re-runs when they change |
tanstack-querytanstack-starttanstack-tabletanstack-integrationfromstrict: false