tanstack-router-guide

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

3|Updated Apr 5, 2024
One-click install
npx skills add https://github.com/danghungtb26/admin-react-typescript-template --skill tanstack-router-guide
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tanstack-router-guide
Source: https://github.com/danghungtb26/admin-react-typescript-template/tree/main/.agents/skills/tanstack-router-guide
Command: npx skills add https://github.com/danghungtb26/admin-react-typescript-template --skill tanstack-router-guide

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

TanStack Router helps teams build scalable, type-safe routing in React using file-based routes, reducing boilerplate and navigation errors.

Core Features & Use Cases

  • File-based routing: map URLs to TS/TSX files under src/routes to mirror app structure.
  • Data loading and navigation: declare loaders, loaderDeps, and navigation helpers to manage data flow and transitions.
  • Protected routes and redirects: beforeLoad guards and route context to enforce authentication and permissions.

Quick Start

Create a new TanStack Router example by adding a root route and several file-based routes under src/routes, then wire up navigation with Link and useNavigate. Start the dev server to explore routes like /, /login, and protected sections. Use the guide to implement routing, route guards, and data loading in your React app.

Frequently Asked Questions about tanstack-router-guide

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 in React?

File-based routing in TanStack Router maps URLs to TS/TSX files under src/routes to mirror your app structure. You create a root route and file-based routes, then wire up navigation using Link and useNavigate helpers.

How do loaders manage data loading and navigation in TanStack Router?

Loaders in TanStack Router manage data loading and navigation by declaring loaders and loaderDeps to control data flow and transitions. This approach reduces boilerplate and navigation errors in React applications.

How do I implement protected routes and redirects in TanStack Router?

Protected routes and redirects in TanStack Router are implemented using beforeLoad guards and route context to enforce authentication and permissions. This secures protected sections of your React application.

Does TanStack Router support type-safe navigation and search params?

TanStack Router supports type-safe navigation, route parameters, and search params to reduce navigation errors. It enforces type-safe routing in React applications using file-based routes and TypeScript.

What is the best way to structure scalable routing in a React app?

The best way to build scalable, type-safe routing in React is using TanStack Router's file-based routes. This approach reduces boilerplate and navigation errors by mapping URLs to TS/TSX files under src/routes.

Why does TanStack Router enforce YAML frontmatter in SKILL.md?

TanStack Router enforces YAML frontmatter with name and description in SKILL.md to maintain metadata consistency. It also supports optional scripts, references, and assets directories to extend functionality.