router
🤖 A client-first, server-capable, fully type-safe router and full-stack framework for the web (React and more).
Type-safe routing library for React apps that catches URL and navigation mistakes at write-time, with built-in data caching and server-side rendering via TanStack Start.
TanStack Router is an open-source library for building web applications in TypeScript. Its main job is to handle navigation inside a web app, meaning it controls what appears on screen when a user clicks a link or types a URL. The project also includes TanStack Start, a companion framework built on top of Router that handles the full stack, including rendering pages on the server before sending them to the browser.
The defining feature of TanStack Router is that it is fully type-safe from end to end. Type safety is a programming concept where the tools catch mistakes at the moment you write code rather than when a user encounters a bug in production. In this case, every route, every URL parameter, and every piece of data loaded for a page is checked automatically, so a developer knows immediately if something is mismatched. Search parameters in the URL are also schema-driven, meaning they follow a defined structure and are validated automatically rather than treated as raw text.
On the performance side, the router includes built-in caching, prefetching (loading data before a user clicks a link so the transition feels instant), and cache invalidation (clearing stale data when it changes). It supports nested layouts, which means different parts of the page can update independently without reloading the whole screen. It also handles error boundaries, which are defined points in the app that catch problems gracefully instead of crashing the entire page.
TanStack Start extends all of these features to the server. It supports full-document server-side rendering (generating the complete HTML on the server before sending it to the browser, which improves load times and search-engine visibility), streaming (sending parts of the page incrementally as they become ready), and server functions that can be called from the browser with the same type safety guarantees. The framework is designed to produce production-ready builds that can be deployed to a range of hosting providers.
Both TanStack Router and TanStack Start are written in TypeScript and are primarily aimed at React-based projects, though the description notes they are designed with support for other libraries in mind. The community is active, with discussion on GitHub and a Discord server for real-time help.
Where it fits
- Build a React app where every URL route, parameter, and loaded data is automatically type-checked, so bugs are caught before they reach users.
- Add prefetching to your React app so navigation feels instant by loading data before a user clicks a link.
- Use TanStack Start to render React pages on the server for faster initial load times and better search-engine visibility.
- Structure a complex web app with nested layouts where different page sections update independently without full reloads.