App Router foundations · core
File-system routing and special files
In the App Router each folder under app/ is a route segment, page.tsx makes it reachable, layout.tsx wraps it and stays mounted across navigation, and special files (loading, error, not-found, route) add Suspense, error and API behaviour per segment.
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceThe notes
What you must know
- Only
page.tsx(UI) androute.ts(Route Handler) make a segment public; other files can be colocated safely. Aroute.tscannot sit in the same segment as apage.tsx. layout.tsxwraps its segment and children and does not re-render or lose state on navigation between its child pages (partial rendering). The root layout is required and must render<html>and<body>; it replaces_appand_document.template.tsxis like a layout but remounts on every navigation (useful for enter animations or per-page effects).loading.tsxwraps the page in a Suspense boundary;error.tsxwraps it in an error boundary (client component);not-found.tsxrenders fornotFound().- Dynamic segments:
[id], catch-all[...slug](one or more), optional catch-all[[...slug]](zero or more). Route groups(marketing)organise without changing the URL;_privatefolders are never routes. paramsandsearchParamsare Promises:const { id } = await params. Sync access was deprecated in 15 and removed in 16. Typed helpers:PageProps<"/blog/[slug]">,LayoutProps<...>,RouteContext<...>.- Next.js 16.3 root params:
import { lang } from "next/root-params"reads params above the root layout (like[lang]) from any Server Component without prop drilling. - Layouts and pages are Server Components by default.
The red pen
Common traps: mistake → fix
Mistake: "Every file in
app/becomes a route"Fix: only
pageandroutefiles are public.Mistake: "Layouts re-render on every navigation, so they are a good place for auth checks"
Fix: they persist; do auth close to the data.
Mistake: "
params.idworks directly"Fix: in Next 15+
paramsis a Promise; in 16 sync access is removed.
Easy to hard
Questions interviewers ask, easy to hard
- How does routing work in the App Router?
- What is the difference between
layout.tsxandtemplate.tsx? - What do
[slug],[...slug],[[...slug]]and(group)mean? - Why are
paramsandsearchParamspromises now? - Design the route tree for a store with marketing pages, a shop and a signed-in account area.
Practise
Practise with these questions
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceYour first interview is free
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.