TanStack Router Examples
Source: github.com/TanStack/router/tree/main/examples/react | Chapters: 24 (4 Quickstart & Basics + 2 Kitchen Sink + 4 Rendering & Data + 2 Search Params & Validation + 4 Navigation & UX + 1 Auth + 4 Third-Party Integrations + 3 Monorepo Setups) | Generated: 2026-08-25
How to Use This Skill
- Without arguments: load the cheatsheet below to pick which example fits your use case
- With a technique name: ask about
SSR streaming, search param validation, route masking, auth guard, etc.; I find and read the matching chapter
- With a chapter: ask for
ch009; I load that specific example
- Browse: ask "what examples do you have?" to see the full index
Each chapter documents one real example project's routing setup with an actual code excerpt, not a rewritten tutorial. For the full project, clone TanStack/router and look at examples/react/<name>.
Which Example to Start From
- Brand-new app, no strong opinions ->
quickstart-file-based (Ch 1), the smallest file-based setup.
- Prefer no code-generation step ->
quickstart (Ch 2) or basic (Ch 4), routes defined inline with createRoute.
- Need nested layouts, pathless layouts, or a dynamic
$param route as a template -> basic-file-based (Ch 3).
- Want a realistic multi-section reference app to copy wholesale ->
kitchen-sink-file-based (Ch 5), or the React Query variant kitchen-sink-react-query-file-based (Ch 6).
- Need server-side rendering, optionally with streaming for slow data ->
basic-ssr-file-based (Ch 7) / basic-ssr-streaming-file-based (Ch 8).
- Have slow, non-critical data that shouldn't block first paint ->
deferred-data (Ch 9).
- Worried about route-tree scale ->
large-file-based (Ch 10).
- Need default or validated search params ->
basic-default-search-params (Ch 11) / search-validator-adapters (Ch 12, Zod/Valibot/ArkType).
- Building modal-over-list UI, unsaved-changes guards, scroll restoration, or native page-transition animation ->
location-masking / navigation-blocking / scroll-restoration / view-transitions (Ch 13-16).
- Need a login-gated section of the app ->
authenticated-routes (Ch 17).
- Fetching data with TanStack Query, tRPC, or animating with Framer Motion, or building an i18n app -> Ch 18-21.
- Splitting the router across a pnpm/turborepo workspace ->
router-monorepo-simple (Ch 22), progressing to lazy loading (Ch 23) and a shared query package (Ch 24).
Full decision table and more detail: cheatsheet.md.
Chapter Index
Quickstart & Basics
| # | Title | Demonstrates |
|---|
| ch001 | Quickstart (File-Based Routing) | Minimal file-based route tree, routeTree.gen.ts, RouterProvider setup |
| ch002 | Quickstart (Code-Based Routing) | Same minimal app with routes defined inline via createRoute, no codegen |
| ch003 | Basic Routing (File-Based) | Nested layouts, pathless layout routes, $postId dynamic param route |
| ch004 | Basic Routing (Code-Based) | Code-based tree with a .lazy.tsx split component file |
Kitchen Sink (Full-Featured Demo)
| # | Title | Demonstrates |
|---|
| ch005 | Kitchen Sink (Full-Featured Demo) | Auth-gated dashboard, invoices, route groups, nested pathless layouts |
| ch006 | Kitchen Sink with React Query | Same reference app with TanStack Query queryOptions driving loaders |
Rendering & Data
| # | Title | Demonstrates |
|---|
| ch007 | SSR (File-Based) | Server-side rendering entry points, router context for <head> |
| ch008 | SSR with Streaming | Streaming SSR response so deferred loader data flushes incrementally |
| ch009 | Deferred Data | defer() + <Await> for non-blocking slow loader data |
| ch010 | Large Route Trees | Code-generated large route tree, scale considerations |
Search Params & Validation
| # | Title | Demonstrates |
|---|
| ch011 | Default Search Params | Fallback values when a search param is absent from the URL |
| ch012 | Search Param Validator Adapters | Same route validated via Zod, Valibot, and ArkType adapters |
Navigation & UX
| # | Title | Demonstrates |
|---|
| ch013 | Location Masking | Displaying a different URL than the internally matched route |
| ch014 | Navigation Blocking | useBlocker guarding against unsaved-change navigation |
| ch015 | Scroll Restoration | Automatic scroll position save/restore across navigations |
| ch016 | View Transitions | Native View Transitions API wired into route navigation |
Auth
| # | Title | Demonstrates |
|---|
| ch017 | Authenticated Routes | Auth guard via pathless layout route + beforeLoad redirect |
Third-Party Integrations
| # | Title | Demonstrates |
|---|
| ch018 | TanStack Query Loader Integration | queryOptions shared between route loader and component |
| ch019 | tRPC + React Query Integration | End-to-end typed tRPC calls inside route loaders |
| ch020 | Framer Motion Page Transitions | Animating route enter/exit with Framer Motion |
| ch021 | i18n with Paraglide | Internationalized routes with the Paraglide JS library |
Monorepo Setups
| # | Title | Demonstrates |
|---|
| ch022 | Monorepo Setup (Simple) | Router/feature/app split across pnpm workspace packages |
| ch023 | Monorepo Setup with Lazy Loading | Same split with lazy-loaded route components across packages |
| ch024 | Monorepo Setup with React Query | Same split with a dedicated post-query package |
Supporting Files