tanstack-router

Build type-safe route trees with validated search parameters and loaders.

Updated Jul 2, 2025
One-click install
npx skills add https://github.com/janpeterd/dotfiles --skill tanstack-router-janpeterd
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tanstack-router
Source: https://github.com/janpeterd/dotfiles/tree/main/dot_agents/skills/tanstack-router
Command: npx skills add https://github.com/janpeterd/dotfiles --skill tanstack-router-janpeterd

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

TanStack Router removes the friction of building React/Solid navigation by providing a fully type-safe routing foundation with validated URL search params and structured data loading, so route behavior stays correct as your app grows.

Core Features & Use Cases

  • Type-safe file and code-based routing: Define routes as a strongly typed route tree (including file-based routing).
  • First-class search parameter validation: Validate and parse search params to ensure correct types and defaults at the routing layer.
  • Integrated data loading and routing lifecycle: Attach loaders, dependencies, preloading, error/pending/not-found handling, and authentication guards via hooks like beforeLoad.

Use case example: A posts app where /posts/$postId validates page, filter, and sort from the URL, loads the corresponding post data in a loader, and cleanly handles loading and not-found states without scattered fetching logic.

Quick Start

Instruct the AI to generate a TanStack Router route setup for a /posts/$postId page that validates search params, loads data in a loader, and wires up pending and not-found components.

Frequently Asked Questions about tanstack-router

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

FAQPage Schema
How do I validate URL search parameters in a React routing setup?

Validating URL search parameters in React requires a type-safe routing layer that parses and validates search params at the routing level. This ensures correct types and defaults are enforced before navigation completes, preventing runtime bugs from inconsistent URL handling.

What is the best way to load route data before rendering a component in Solid?

Loading route data before rendering in Solid is best handled by integrated route loaders. Loaders fetch dependencies during the routing lifecycle, allowing the application to preloading data and cleanly manage pending and not-found states without scattered fetching logic.

How do I build a type-safe route tree for nested and dynamic routes?

Building a type-safe route tree for nested and dynamic routes involves defining routes as a strongly typed structure, either via file-based routing or code-based configuration. This creates a fully typed foundation that ensures route behavior stays correct as the application scales.

Does TanStack Router support authentication guards and redirect handling?

TanStack Router supports authentication guards and redirect handling through routing lifecycle hooks like beforeLoad. These hooks allow you to configure proper navigation behaviors, intercept route access, and trigger redirects before the route renders.

Why should I use type-safe routing instead of standard React Router?

Type-safe routing prevents runtime navigation bugs by validating URL search params and providing a strongly typed route tree. Unlike standard routing, it enforces correct types and defaults at the routing layer, ensuring consistent URL handling and structured data loading as your app grows.

How do I handle not-found and pending states when loading route data?

Handling not-found and pending states during route data loading is done by wiring up dedicated components within the routing lifecycle. By attaching loaders and configuring proper navigation behaviors, the application cleanly manages loading transitions and missing resource states.