Next.js Developer interview question · Most asked
Explain the App Router file conventions: page, layout, loading, error, not-found, template and route.
Summary
page.tsx defines a route's UI; layout.tsx wraps child segments and persists across navigation; loading.tsx is an automatic Suspense fallback; error.tsx is an error boundary (must be a Client Component); not-found.tsx renders for notFound(); template.tsx is like a layout but remounts on navigation; route.ts defines HTTP handlers.
Longer Answer
Folders define URL segments, and only folders with page.tsx or route.ts are publicly routable, so you can colocate components. global-error.tsx catches errors in the root layout. Layouts don't re-render on navigation between child pages, which preserves state.
Key Points
- Folders = segments;
page/routemake them routable - Layouts persist, templates remount
loading.tsx→ Suspenseerror.tsxmust be'use client'
More most-asked Next.js Developer questions
- How did caching defaults change in Next.js 15?
- Explain SSR, SSG, ISR and CSR in Next.js.
- How does data fetching work in the App Router?
- What is Next.js and what problems does it solve on top of React?
- What are the differences between the App Router and the Pages Router?
- What is the difference between Server Components and Client Components?
- What happens, step by step, when a request reaches a Next.js App Router application?
- What are Server Actions and how do you use them for mutations?