Next.js Interview Questions
171 curated questions graded from Foundations (Easy) to Practical Patterns (Medium) and Internals & Architecture (Hard).
171
150
21
5 / Level
Foundations & Core Concepts
Q1What is Next.js, and what are its key advantages over a vanilla React SPA?
Answer: Next.js is a production-ready React meta-framework that enables hybrid rendering rendering strategies (SSR, SSG, ISR, CSR) out of the box.
- Server-Side Pre-rendering: Delivers pre-rendered HTML to the client, improving SEO and Initial Page Load (LCP).
- Built-in Optimizations: Features native components for optimizing images (
next/image), scripts (next/script), fonts (next/font), and routes (next/link). - Zero Config: Automatically configures Webpack/Turbopack code splitting, compilation, and minification.
- Hybrid Data Fetching: Allows different rendering methods on a page-by-page basis.
Q2Explain the core differences between CSR, SSR, SSG, and ISR rendering models.
Answer:
- CSR (Client-Side Rendering): The server sends a bare-bones HTML page containing a JavaScript bundle. The browser downloads and executes the JS to build the UI at runtime.
- SSR (Server-Side Rendering): Pre-renders HTML on the server for each incoming request. Best for dynamic, user-specific data that must be search-engine crawlable.
- SSG (Static Site Generation): Pre-renders HTML at build time. HTML files remain static on a CDN. Best for static assets like blogs or marketing sites.
- ISR (Incremental Static Regeneration): Regenerates static pages in the background periodically after the build has finished, without needing a full rebuild.
Q3What are the main differences between the Pages Router and the App Router?
Answer:
- Routing Architecture: Pages Router routes are determined by files in the
/pagesdirectory. App Router is built on the/appdirectory where folders define routes and apage.jsfile serves as the route leaf. - Default Component Type: Pages Router uses standard React components (Client Components). App Router leverages React Server Components (RSC) by default.
- Layout Management: Pages Router uses custom
_app.jsand_document.jsfor global layouts. App Router supports nested layouts usinglayout.jsat any route level. - Data Fetching: Pages Router uses
getStaticPropsandgetServerSideProps. App Router uses standard asyncfetch()with custom cache configurations inside Server Components.
Q4What is the purpose of `_app.js` and `_document.js` in the Pages Router?
Answer:
_app.js: Custom root wrapper that initializes pages. Used for persistent layouts, global CSS imports, state providers (e.g., Redux, React Query), and page-change tracking. Runs on both server and client._document.js: Custom HTML shell renderer. Used to inject<html>attributes, language codes, custom fonts, or SSR CSS-in-JS styles. Only runs on the server and cannot use React hooks or client-side logic.
Q5How does Dynamic Routing work in the App Router vs Pages Router?
Answer: Both use bracket syntax, but structure files differently:
- Pages Router: File
pages/post/[id].jsmaps to/post/:id. - App Router: Folder
app/post/[id]/page.jsmaps to/post/:id. - Catch-All Routing: Brackets with an ellipsis
[...slug]map to nested sub-routes (e.g.,/post/a/b/c). - Optional Catch-All: Double brackets
[[...slug]]match the base route as well as nested sub-routes (e.g., matching/postas well as/post/a/b).
Unlock the complete Next.js Easy question bank
Get instant access to all 57 questions, in-depth model answers, code sandboxes, and all 27+ technologies for a single one-time payment.
Browse All Next.js Questions by Difficulty
Core concepts, definitions, basic syntax, and first principles expected in round 1 screening.
Real-world mechanisms, state management, edge cases, performance trade-offs, and practical coding.
Deep runtime internals, memory models, distributed design, concurrency failure modes, and architectural decisions.