Skip to content

TanStack Router

★ New
trial
Frontend open-source MIT open-source

At a Glance

Fully type-safe client-side router for React (and Solid) with first-class search-parameter handling, nested layouts, and built-in data loading; positioned as a type-safe alternative to React Router.

Type
open-source
Pricing
open-source
License
MIT
Adoption fit
small, medium

What It Does

TanStack Router is a client-side routing library for React (with Solid support) that takes a “state-first” approach: the URL is treated as structured, typed state rather than a simple string path. The library auto-generates TypeScript types for all routes, path parameters, and search parameters at build time via a code-generation step, providing end-to-end type safety between navigation calls and route components.

Unlike React Router — which has historically been UI-first (URL resolves to a component tree) — TanStack Router treats search parameters as first-class typed state, which eliminates entire categories of bugs where URL query string manipulation produces runtime type errors or component inconsistencies.

Key Features

  • Fully inferred TypeScript types for routes, params, and search params — navigation calls are type-checked at compile time
  • First-class search parameter handling with runtime validation (Zod, Valibot, ArkType) and serialization/deserialization built in
  • File-based routing (optional) with code generation for route types, plus programmatic/code-based routing for teams that prefer explicit declarations
  • Nested layouts and route contexts with React Suspense-first data loading
  • Built-in data loader API (works standalone or integrated with TanStack Query)
  • Route masking — display one URL while the internal route resolves differently (useful for modal routing patterns)
  • Navigation blocking — prompt users before navigating away from unsaved forms
  • SSR support via TanStack Start integration
  • Migration paths from React Router v6 and React Location (official guides provided)

Use Cases

  • Use case 1: TypeScript-heavy React SPAs where type-safe navigation calls and validated search params reduce runtime errors
  • Use case 2: Applications using URL as shared state (filters, pagination, modal state) that need reliable serialization
  • Use case 3: Teams migrating from React Router who want stronger type safety without adopting a full framework
  • Use case 4: Pairing with TanStack Query for co-located, type-safe route-level data loading

Adoption Level Analysis

Small teams (<20 engineers): Fits for TypeScript-first teams building greenfield React SPAs. The code generation step adds some tooling overhead but is manageable. Caution: the file-based routing pattern requires buy-in to a specific project structure from day one.

Medium orgs (20–200 engineers): Reasonable fit for teams with strong TypeScript discipline. The type-safe search parameter handling is genuinely valuable at this scale where multiple teams share URL state conventions. However, the smaller ecosystem (fewer third-party integrations, community plugins) compared to React Router means more custom work.

Enterprise (200+ engineers): Not recommended as a primary enterprise standard yet. React Router v7 has closed the gap on type safety in framework mode, has a vastly larger ecosystem, and has enterprise backing (Shopify). TanStack Router’s sponsorship-only sustainability model is a risk at this scale. Assess for new TypeScript-first projects but do not mandate.

Alternatives

AlternativeKey DifferencePrefer when…
React Router v7Larger ecosystem, Shopify-backed, framework mode with type safety, but search param types require manual workStability, ecosystem breadth, and enterprise backing are priorities
Next.js App RouterIntegrated with React Server Components and Vercel deploymentFull-stack framework features and RSC are needed
Remix (React Router v7 framework mode)Server-first data loading, progressive enhancement philosophyTeams wanting server-rendered forms and data mutations via web fundamentals
AstroStatic-first with optional islandsMostly static content sites that don’t need full SPA routing

Evidence & Sources

Notes & Caveats

  • Code generation dependency: The type-safe route tree requires a build-time codegen step. This adds CI complexity and means the TypeScript types lag file system changes until regenerated — a minor friction in watch mode that can confuse developers unfamiliar with the pattern.
  • React Router gap is closing: React Router v7 in framework mode has adopted many of TanStack Router’s type safety features. For teams already on React Router, the cost of migrating may outweigh the incremental type safety gains.
  • Non-React framework support is limited: Despite TanStack’s framework-agnostic branding, the router is React-first. Vue, Svelte, and Angular teams cannot use TanStack Router and should not be misled by the “framework agnostic” marketing applied to the broader TanStack ecosystem.
  • RSC support absent: TanStack Router operates on the client-side routing model. It does not integrate with React Server Components natively. This is a deliberate architectural choice but one that diverges from where the React core team is investing.
  • v1 is the current version: Despite “v1” branding implying stability, the library is younger than React Router (which has existed since 2014). Production battle-testing at scale is less extensive.

Related