Capítulo 13 de 57
Migrating from React Router to TanStack Router is a checklist-driven process: install TanStack Router, optionally uninstall react-router-dom to surface TypeScript errors on every remaining import, rebuild routes/root route/router instance, swap Link/useNavigate/Outlet/useParams, and move useSearchParams state into validateSearch plus useSearch.
react-router-dom forces TypeScript compile errors at every leftover import, giving a reliable checklist of what still needs conversion (faster than grepping manually).useNavigate outside of context" in the console typically means a stray React Router API is still being called somewhere.Link differences: TanStack Router's Link requires a literal to path prop, plus a params prop for dynamic segments, e.g. params={{ orderId: order.id }}.useNavigate differences: Same to/params pattern as Link is used with the @tanstack/react-router useNavigate hook.useSearchParams hook is replaced by defining a validateSearch property on the route, then reading values with useSearch({ from: fullPath }) and updating them via Link's search prop.useParams differences: Requires a from property naming the literal route path (e.g. useParams({ from: "/orders/$orderId" })), then accessing fields off the returned params object.const { page } = useSearch({ from: productPage.fullPath })
useSearchParams hook.const params = useParams({ from: '/orders/$orderId' })
// params.orderId
from property pointing at the literal route path.react-router-dom early in the migration to let TypeScript surface every remaining call site needing conversion, this is faster and more reliable than manual searching.Link, useNavigate, Outlet, useParams, and useSearchParams one at a time; each has a direct but not identical TanStack Router equivalent requiring to/params/from wiring.useSearchParams logic and into a route's validateSearch, this is the biggest structural change, not just an API rename.