D
DevPrepSystematic Prep
DEVPREP CODEX · #13

Next.js Interview Questions

171 curated questions graded from Foundations (Easy) to Practical Patterns (Medium) and Internals & Architecture (Hard).

TOTAL QUESTIONS

171

THEORY QUESTIONS

150

IMPLEMENTATION FOLIOS

21

FREE QUESTIONS

5 / Level

Easy Level·57 Questions Total

Foundations & Core Concepts

Open Full Easy List
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 /pages directory. App Router is built on the /app directory where folders define routes and a page.js file 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.js and _document.js for global layouts. App Router supports nested layouts using layout.js at any route level.
  • Data Fetching: Pages Router uses getStaticProps and getServerSideProps. App Router uses standard async fetch() 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].js maps to /post/:id.
  • App Router: Folder app/post/[id]/page.js maps 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 /post as well as /post/a/b).

52 More Easy Questions Locked

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.

Unlock All — One-time payment · Lifetime access
DEDICATED LEVEL PAGES

Browse All Next.js Questions by Difficulty

INTERNAL LINKING & DEPENDENCIES

Related Technologies to Next.js

CAREER PATHWAYS

Next.js is a key requirement for these engineering roles:

Next.js Interview Questions — Easy, Medium & Hard | DevPrep | DevPrep