Route Naming Cheat Sheet
Directory-Based Routing — TanStack Router
File Types
| File/Folder |
Purpose |
Example |
route.tsx |
Layout route — wraps children |
settings/route.tsx → /settings |
index.tsx |
Index route — renders at parent |
settings/index.tsx → /settings |
__root.tsx |
Root layout — wraps entire app |
Always rendered |
Special Prefixes
$param — Dynamic segment (named)
posts/$postId/route.tsx → /posts/42 (params.postId)
$ — Splat route (catch-all, bare dollar)
files/$/route.tsx → /files/a/b/c (captured in params._splat)
_folder — Pathless route
_authenticated/route.tsx → wraps children, no URL segment
(folder) — Route group
(marketing)/about/route.tsx → /about (organization only)
Examples
routes/
├── __root.tsx
├── _app/
│ ├── route.tsx → pathless layout
│ └── index.tsx → /
├── posts/
│ ├── route.tsx → /posts
│ └── $postId/
│ └── route.tsx → /posts/42
└── files/
└── $/
└── route.tsx → /files/a/b/c (params._splat)
Next.js ↔ TanStack Router Quick Map
| Next.js | TanStack Router (Directory) | Note |
app/page.tsx | routes/index.tsx | Home at / |
app/layout.tsx | routes/__root.tsx | Root layout (always rendered) |
app/about/page.tsx | routes/about/route.tsx | Static page |
app/[id]/page.tsx | routes/$id/route.tsx | Dynamic segment |
app/(shop)/page.tsx | routes/(shop)/route.tsx | Group dir — organizational only |
app/[...slug]/page.tsx | routes/files/$/route.tsx | Splat → params._splat |
Common Mobile App Patterns
Tab-based app with detail screens
routes/
├── __root.tsx
├── _app/
│ ├── route.tsx → Bottom tabs layout (pathless)
│ ├── index.tsx → Home tab
│ ├── explore/
│ │ └── route.tsx → Explore tab
│ └── profile/
│ └── route.tsx → Profile tab
└── posts/
└── $postId/
└── route.tsx → Detail pushed over tabs
Key Points
- Folders = path segments
route.tsx creates layout routes (can have children)
index.tsx creates terminal routes (no children)
$param prefix = dynamic segment (named param)
$ alone = splat (catch-all → params._splat)
_ prefix = pathless (no URL segment)
( ) wraps = route group (file organization)