Next.js Developer interview question · Most asked
What happens, step by step, when a request reaches a Next.js App Router application?
Summary
next.config headers, redirects and rewrites apply; the proxy (middleware.ts before Next.js 16) runs for matched paths and may redirect, rewrite or respond; routing serves static assets directly or matches an app route; server components render on the server (fetching data, using caches where configured) to HTML for the first load or an RSC payload for client navigations; route handlers and server actions handle API requests and mutations; in the browser, client components hydrate and links prefetch routes.
Longer Answer
Consequences: a proxy without a matcher runs for every asset and prefetch, so keep it cheap and authorise near the data (server components, route handlers, server actions). Layouts persist across client navigations, so they don't re-run for every page change.
Key Points
- Config redirects/rewrites → proxy → routing.
- Server components render on the server.
- Route handlers and server actions for APIs and mutations.
- Client components hydrate; links prefetch.
Deep dive: Request Lifecycle course: Next.js: Proxy (Middleware), Rendering and Caching
Explanation
What interviewers look for
The full order and the proxy matcher and authorisation implications.
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 are the differences between the App Router and the Pages Router?
- What is the difference between Server Components and Client Components?
- Explain the App Router file conventions: page, layout, loading, error, not-found, template and route.
- What is Next.js and what problems does it solve on top of React?
- What are Server Actions and how do you use them for mutations?