tanstack-router-migration

Migrate React applications from React Router to TanStack Router with file-based routing.

4.3k|430|Updated Sep 29, 2019
One-click install
npx skills add https://github.com/redpanda-data/console --skill tanstack-router-migration
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tanstack-router-migration
Source: https://github.com/redpanda-data/console/tree/main/frontend/.claude/skills/tanstack-router-migration
Command: npx skills add https://github.com/redpanda-data/console --skill tanstack-router-migration

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @tanstack/react-router, @tanstack/router-plugin, @tanstack/zod-adapter, zod, and includes references (resource) components.

What problem does it solve?

Migrating a React application from React Router to TanStack Router involves many coordinated changes: build plugin configuration, file-based route restructuring, hook replacements, search param validation, and test setup. This Skill provides a structured, phase-by-phase migration process that prevents common mistakes like missing from parameters, broken type inference, and navigation loops.

Core Features & Use Cases

  • Phased Migration Workflow: Seven phases covering assessment, build setup, router creation, route migration, hook migration, testing, and integrations (Sentry, nuqs).
  • Type-Safe Patterns: Enforces from parameters in hooks, Zod-validated search params via @tanstack/zod-adapter, and router type registration for full TypeScript inference.
  • Incremental Migration Support: Reference guides for running React Router and TanStack Router side-by-side, including a RouterSync bridge component and embedded-mode shell synchronization.
  • Use Case: A team maintaining a large React Router codebase wants type-safe routing. Use this Skill to audit existing routes, configure the Rspack/Vite plugin, convert routes to src/routes/ file-based structure, and migrate hooks one component at a time without breaking the app.

Quick Start

Migrate my React app from React Router to TanStack Router using file-based routing, starting with an audit of existing routes and hooks.

Frequently Asked Questions about tanstack-router-migration

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

FAQPage Schema
How do I migrate from React Router to TanStack Router?

Follow a phased approach: audit existing React Router usage, configure the TanStack Router build plugin, create a file-based routes directory, migrate routes and hooks incrementally, then remove React Router. The skill supports running both routers together during transition.

How do I replace useSearchParams with TanStack Router?

Define a Zod schema in the route file and pass it to validateSearch using zodValidator from @tanstack/zod-adapter. Then read values with routeApi.useSearch() and update them via navigate({ search: (prev) => ({ ...prev, key: value }) }).

Does TanStack Router support incremental migration with React Router?

Yes. You can wrap the TanStack Router root layout in a BrowserRouter and use a RouterSync component to bridge navigation to legacy code. Routes migrate one at a time until React Router can be removed entirely.

Why is my TanStack Router useParams not type-safe?

Type safety requires the from parameter matching the exact route path, including trailing slashes for index routes. You must also register the router type via declare module '@tanstack/react-router' with the Register interface.

Can I edit the routeTree.gen.ts file in TanStack Router?

No. routeTree.gen.ts is auto-generated by the build plugin whenever route files change. Editing it manually causes conflicts; instead configure the plugin options and let it regenerate. Many teams commit it to version control.

How do I test file-based routes in TanStack Router with Vitest?

Create a test utility using createMemoryHistory and createRouter with your generated routeTree, then render with RouterProvider. Add the tanstackRouter Vite plugin to your Vitest config so the route tree generates during tests.