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.jsTanStack Router (Directory)Note
app/page.tsxroutes/index.tsxHome at /
app/layout.tsxroutes/__root.tsxRoot layout (always rendered)
app/about/page.tsxroutes/about/route.tsxStatic page
app/[id]/page.tsxroutes/$id/route.tsxDynamic segment
app/(shop)/page.tsxroutes/(shop)/route.tsxGroup dir — organizational only
app/[...slug]/page.tsxroutes/files/$/route.tsxSplat → 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