tanstack-router

Organize file-based routes with type-safe patterns in TanStack Router.

1|Updated Jan 22, 2026
One-click install
npx skills add https://github.com/oakoss/open-saas-kit --skill tanstack-router-oakoss
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tanstack-router
Source: https://github.com/oakoss/open-saas-kit/tree/main/.claude/skills/tanstack-router
Command: npx skills add https://github.com/oakoss/open-saas-kit --skill tanstack-router-oakoss

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

TanStack Router file-based routing enables scalable route trees and consistent UI patterns in React apps by formalizing routes as files and folders.

Core Features & Use Cases

  • File-based routing for nested layouts, loaders, and guards
  • Type-safe navigation and params across complex route hierarchies
  • Use cases: building admin dashboards, public/private sections, and API routes with shared layouts

Quick Start

  • Create a route by adding files under routes/ and exporting a Route using createFileRoute from @tanstack/react-router.
  • Wire up a router with createRouter and a routeTree, then render with a RouterProvider.
  • Use loaders, beforeLoad guards, and route context to implement authentication and data fetching.

Frequently Asked Questions about tanstack-router

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

FAQPage Schema
How do I organize file-based routes for complex nested layouts in React?

File-based routing in React organizes scalable route trees by formalizing routes as files and folders under a routes directory. You define routes using createFileRoute, wire up a router with createRouter, and render nested layouts via RouterProvider.

How do I implement authentication guards and data fetching before a route loads?

Authentication guards and data fetching use beforeLoad guards and loaders within your route definitions. You configure these lifecycle functions alongside route context to block navigation or fetch API data before rendering the route component.

Do I need TypeScript to use file-based routing with TanStack Router?

Yes, TypeScript is required to enforce type-safe routing patterns, frontmatter metadata, and route context. TanStack Router relies on TypeScript to validate loaders, beforeLoad guards, and type-safe navigation across complex route hierarchies.

What is the best way to structure public and private sections in a React app?

The best way to structure public and private sections is using file-based routing with shared layouts and beforeLoad guards. You define route files for each section, apply authentication guards, and share layout components across the route hierarchy.

Why does my route context fail when setting up loaders and beforeLoad guards?

Route context failures often occur when frontmatter metadata is missing or loaders and beforeLoad guards are improperly configured. You must enforce TypeScript types and ensure route context is correctly passed through your createFileRoute definitions.