tanstack-router

Configure type-safe file-based routes for React with TanStack Router.

278|29|Updated Nov 4, 2025
One-click install
npx skills add https://github.com/MadAppGang/claude-code --skill tanstack-router-madappgang
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tanstack-router
Source: https://github.com/MadAppGang/claude-code/tree/main/plugins/frontend/skills/tanstack-router
Command: npx skills add https://github.com/MadAppGang/claude-code --skill tanstack-router-madappgang

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @tanstack/react-router, @tanstack/router-plugin.

What problem does it solve?

Managing routing in complex React applications can lead to untyped parameters, manual route definitions, and difficult navigation. This Skill provides patterns for type-safe, file-based routing with TanStack Router.

Core Features & Use Cases

  • File-Based Routing: Define routes automatically by file structure, simplifying route management.
  • Type Safety: Get full TypeScript inference for route parameters, search parameters, and loader data.
  • Route Loaders: Prefetch data before navigation completes, ensuring instant perceived performance.
  • Layouts & Guards: Implement shared UI layouts and authentication guards easily.
  • Use Case: Set up a /users/:userId route that automatically infers the userId parameter type, prefetches user data using a loader, and displays a loading spinner during data fetch.

Quick Start

Use the tanstack-router skill to set up a new file-based route for /users/$userId.

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 type-safe file-based routing in a React application?

File-based routing in React automatically generates routes from your file structure, eliminating manual route definitions. TanStack Router provides type safety by inferring parameter and search types directly from your route files, reducing runtime errors and improving developer experience with full TypeScript support.

Can I use TanStack Router to prefetch data before navigation completes?

Route loaders in TanStack Router prefetch data before navigation finishes, ensuring instant perceived performance. Define loaders in your route files to fetch user data, API responses, or other async content, and the router automatically handles loading states and data availability.

What's the best way to handle dynamic route parameters with type inference?

TanStack Router infers route parameter types automatically from your file-based route definitions. When you create a `/users/$userId` route, the router generates TypeScript types for `userId`, eliminating manual type declarations and catching parameter mismatches at compile time.

How do I implement authentication guards and shared layouts in React routing?

TanStack Router supports layout routes and guards through its file structure and loader integration. Define parent routes for shared UI layouts and use loaders to authenticate users before rendering, controlling access to protected routes without manual middleware setup.

Does TanStack Router work with existing React projects, or do I need a new setup?

TanStack Router integrates into existing React projects by installing the router package and plugin. The plugin generates your routeTree from your file structure, so you can adopt file-based routing incrementally without rewriting your entire application.