Next.js & App Router (50 Qs)•Part 1: Basic & Foundational Concepts (Junior / Entry-Level)
How does File-Based Routing work in the App Router?
junior LevelRouting
In Simple Words:
Special reserved filenames inside app/ define the UI hierarchy:
page.tsx: Makes the route publicly accessible and defines its unique UI.layout.tsx: Shared UI wrapping the page and its child routes. Preserves state across navigations (does not re-render).loading.tsx: Automatically wrapspage.tsxin a React<Suspense>boundary to display an instant skeleton loader.error.tsx: React Error Boundary that catches runtime errors and shows a fallback UI without breaking the parent layout. (Must be a Client Component).not-found.tsx: Rendered whennotFound()is invoked or a route does not match.