intermediate · 25 minute study
Read an App Router application as a route tree
Framework conventions are easier to navigate when you know which file owns a URL, which file supplies shared UI and which file handles a failure.
Useful preparation · 2 prerequisites
Use this as a map, not a lock. If these ideas are familiar, continue.
- Ask where and when this code runs — The same JavaScript syntax can run during a build, on a request server or inside a browser. Confusing those locations creates broken builds and misplaced trust.
- UI is a description produced from a state snapshot — Understanding rendering makes state updates predictable before you memorize hooks.
First, build a mental model
A route tree maps URL segments to nested UI boundaries. A page is a destination; a layout surrounds destinations; loading and error boundaries describe transitions and recovery.
- Folders define route segments, while page.tsx makes a UI route reachable. A layout composes shared structure around its descendants; the root layout supplies the document shell.
- Dynamic segments such as [slug] represent parameters. A static export must enumerate supported paths using the appropriate static parameter generation rather than inventing new files at request time.
- loading.tsx and error.tsx provide scoped pending/error UI under framework rules. Error recovery must not imply a failed write succeeded, and a layout is not a substitute for authorization at the actual data boundary.
- Metadata describes the document for browsers and crawlers. Route handlers use route.ts for HTTP behavior; their runtime needs depend on what the handler actually does.
{
"app/layout.tsx": "shared document shell",
"app/learn/page.tsx": "/learn",
"app/learn/[slug]/page.tsx": "/learn/<known-slug>",
"app/learn/[slug]/loading.tsx": "pending UI boundary",
"app/learn/[slug]/error.tsx": "recovery UI boundary",
"app/catalog/route.ts": "HTTP response handler"
}- URL
A request for /learn/functions selects the learn and dynamic-slug route segments.
- Composition
The page appears inside the applicable layouts; route structure explains which UI is shared.
- Artifact contract
For a static site, functions must be a generated route. A folder convention alone does not create every possible slug.
Production thinking
Take this beyond the example.
Keep URL design, accessibility landmarks, metadata and failure states deliberate. Validate direct navigation and generated paths as part of the static artifact contract.
Sources and further reading
Your evidence
unseen is a local learning signal, not a credential or proof of production competence.
Explain the mental model, then explicitly acknowledge it. Opening a page is not evidence.
Supported retries can complete this lesson. Independent evidence and delayed review determine the skill stage.
Next lesson · Choose rendering by freshness, authority and cost →