▲ Next.js Intermediate

What is the Next.js App Router folder structure and special files?

Why Interviewers Ask This

Mid-level Next.js roles require deep understanding of this topic. Interviewers ask this to separate candidates who truly understand the mechanics from those who only know surface-level concepts.

Answer

The App Router uses specific file conventions within the app/ directory: Route files: page.tsx — unique UI for a route (makes it publicly accessible); layout.tsx — shared UI, persists across navigations within its segment; template.tsx — like layout but re-mounts on each navigation (for animations, per-route state); loading.tsx — Suspense fallback; error.tsx — error boundary; not-found.tsx — 404 UI (triggered by notFound()); route.ts — API endpoint (HTTP method exports). Metadata files: icon.png / apple-icon.png — favicon; opengraph-image.png — OG image; robots.ts — robots.txt generator; sitemap.ts — sitemap.xml generator; manifest.ts — web app manifest. Folder conventions: [param] — dynamic segment; [...param] — catch-all; [[...param]] — optional catch-all; (group) — route group (no URL effect); _private — opted out of routing; @slot — named slot for parallel routes. Parallel routes: app/@modal/page.tsx — simultaneously render multiple pages; consumed in layout via { modal }: { modal: React.ReactNode }. Intercepting routes: app/(.)photo/[id]/page.tsx — intercept navigation to show a modal while keeping the current page. Global files: app/global-error.tsx — catch root layout errors; app/favicon.ico.

Common Mistake

Candidates often give textbook answers here. Interviewers are more impressed when you relate the concept to a specific problem you solved in a real Next.js project.