tanstack-router

Implements type-safe file-based routing with loaders and search params for React applications.

Updated Feb 27, 2026
One-click install
npx skills add https://github.com/firstaxel/neon --skill tanstack-router-firstaxel
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: tanstack-router
Source: https://github.com/firstaxel/neon/tree/main/.agents/skills/tanstack-router
Command: npx skills add https://github.com/firstaxel/neon --skill tanstack-router-firstaxel

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Building React applications with type-safe navigation, validated search parameters, and route-level data loading is error-prone when done manually. This Skill provides complete guidance for implementing TanStack Router so routes, params, loaders, and redirects stay fully typed and consistent. ## Core Features & Use Cases - File-Based Routing: Generate route trees automatically from file conventions including dynamic params, pathless layouts, and splat routes. - Data Loading & Search Params: Configure route loaders, loaderDeps, deferred streaming with Await, and Zod-validated search parameters. - Navigation & Guards: Implement typed Link components, programmatic navigation, authentication guards via beforeLoad, redirects, and navigation blocking. - Use Case: You are building a dashboard with protected pages and paginated tables. Use this Skill to set up an _authenticated pathless layout, validate page/filter search params with Zod, and preload data on link hover. ## Quick Start Ask the AI to set up TanStack Router file-based routing in your Vite React project with a root layout, an index route, and a dynamic post detail route with a loader.

Frequently Asked Questions about tanstack-router

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set up file-based routing with TanStack Router?▼

Install @tanstack/react-router and add the TanStackRouterVite plugin from @tanstack/router-plugin to your vite.config.ts. Files in your routes directory then automatically generate the route tree using conventions like index.tsx, $param.tsx, and __root.tsx.

How to validate search params in TanStack Router?▼

Use the validateSearch option on a route with a Zod schema or a manual parser function. Validated search params become fully typed and are accessible via Route.useSearch() or the useSearch hook.

Does TanStack Router work with TanStack Query?▼

Yes, TanStack Router integrates with TanStack Query through router context. Pass queryClient in the router context and call queryClient.ensureQueryData inside route loaders, then use useSuspenseQuery in components for reactive updates.

How do I protect routes with authentication in TanStack Router?▼

Use the beforeLoad hook on a pathless layout route like _authenticated to check auth state from router context and throw a redirect to the login page. This prevents protected content from rendering before the check completes.

Why is my TanStack Router loader not refetching when search params change?▼

Loaders do not automatically re-run when search params change unless you declare loaderDeps. Add loaderDeps returning the relevant search params so the loader re-executes whenever those values change.

How do I code split routes in TanStack Router?▼

With file-based routing, create a .lazy.tsx companion file using createLazyFileRoute for the component, pendingComponent, and errorComponent. Keep loaders and beforeLoad in the main route file so they load eagerly.