tanstack-router

Implement type-safe file-based routing with TanStack Router in React applications.

Updated Jan 17, 2026
One-click install
npx skills add https://github.com/AndyMarigoldLabs/continuous-funding --skill tanstack-router-andymarigoldlabs
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tanstack-router
Source: https://github.com/AndyMarigoldLabs/continuous-funding/tree/main/.codex/skills/tanstack-router
Command: npx skills add https://github.com/AndyMarigoldLabs/continuous-funding --skill tanstack-router-andymarigoldlabs

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides a structured approach to implementing type-safe, file-based routing in React applications using TanStack Router, enabling scalable route definitions and predictable navigation.

Core Features & Use Cases

  • Type-safe route definitions via file-based routes that map to the filesystem
  • Dynamic and typed params support, including nested and index routes
  • Layouts, route guards, loaders, and error handling for robust UI flows
  • Programmatic navigation and preloading to optimize user experiences
  • Code-splitting with route.lazy.tsx for performance
  • Use Case: build a multi-page admin interface with shared layouts and dynamic user pages

Quick Start

Install @tanstack/react-router and create a routes directory (e.g., src/routes/). Create files like src/routes/index.tsx, src/routes/about.tsx, and dynamic routes such as src/routes/users/$userId.tsx. Use createFileRoute to declare routes, and Link/useNavigate for navigation.

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 in React with type-safe route definitions?

File-based routing in React maps route files directly to the filesystem using createFileRoute. You create a routes directory, define index and dynamic parameter files, and the system generates type-safe route definitions for predictable navigation.

How does type-safe routing handle dynamic route parameters and nested layouts?

Type-safe routing infers TypeScript types for dynamic parameters like $userId directly from the file name. Nested layouts are managed through file nesting conventions, allowing shared UI wrappers across multiple routes without manual type casting.

What's the best way to load data before rendering a route in a React application?

The best way to load data before rendering a route is using route loaders. Loaders fetch data asynchronously during navigation, passing typed data directly to the route component to ensure the UI is ready before painting.

Can I optimize React app performance by code-splitting routes and preloading data?

Yes, you can optimize React performance by using route.lazy.tsx files for code-splitting. Programmatic preloading fetches data and code chunks before navigation completes, reducing load times during user transitions.

Do I need TypeScript to implement type-safe file-based routing?

Yes, TypeScript is required to implement type-safe file-based routing. The routing mechanism relies on TypeScript to infer types for parameters, navigate programmatically, and ensure route definitions and data loading are predictable.

When should I use file-based routing instead of configuring routes programmatically?

Use file-based routing when building scalable applications with complex nested structures, shared layouts, and dynamic pages. It enforces predictable route definitions mapped to the filesystem, reducing manual configuration errors in large React projects.