Skip to main content
InterviewHubPRO
HomeTracksSection 4: Next.js & App Router (50 Qs)
Section 4 of 6450 Questions (1 Per Page)

Next.js App Router, SSR & Production Infrastructure Master Interview Bank

App Router architecture, Server Actions, partial prerepresenting (PPR), Next.js caching layers, Edge runtime, ISR, dynamic IO, and metadata optimization.

Curriculum Roadmap & Learning Path

3 Stages
Tip: Click any stage card above to instantly filter the question bank to that topic.3 Connected Milestones
50 of 50 Qs

Part 1: Basic & Foundational Concepts (Junior / Entry-Level)

15 Questions
1
Junior#nextjs#Basic

What is Next.js, and how does it extend standard React?

Standard React (Vite / CRA): A client-side library • Next.js: A production full-stack React framework • Server-Side Rendering (SSR) & Static Site Generation (SSG): Pre-renders HTML on the server • React Server Components (RSC): Runs components exclusively on the server, shipping 0KB of JS to the client.

2
Junior#Routing

What are the key differences between the App Router (`app/`) and the legacy Pages Router (`pages/`)?

Feature Legacy Pages Router (pages/) Modern App Router (app/).

3
Junior#CLI#SSR & Hydration

What is Server-Side Rendering (SSR) vs. Static Site Generation (SSG) vs. Client-Side Rendering (CSR)?

CSR (Client-Side Rendering): Empty HTML sent; browser fetches data and renders everything • SSG (Static Site Generation): HTML is generated once at build time (next build) • SSR (Server-Side Rendering): HTML is generated on the server dynamically on every incoming HTTP request.

4
JuniorCode#Apache Kafka

What is Incremental Static Regeneration (ISR) and how does `revalidate` work?

Historically, SSG required rebuilding the entire website whenever content changed in a CMS. ISR allows you to update static pages in the background without rebuilding the whole site.

5
Junior#CLI#Components

What are React Server Components (RSC) and how do they differ from Client Components?

In Next.js App Router, all components are React Server Components by default: RSC (Server Components) • Execute only on the server • Can directly query databases (db.query()), access server files (fs), and use sensitive secrets (process.env.API_SECRET).

6
Junior#Directives#CLI

When should you use the `'use client'` directive?

You only need to add 'use client' at the top of a file when the component requires: React hooks: useState, useReducer, useEffect, useRef • Interactive DOM event listeners: onClick, onChange, onSubmit • Browser APIs: window, document, navigator, localStorage • Custom hooks that depend on client state or context providers.

7
JuniorCode#State Management

What are Server Actions in Next.js (`'use server'`)?

Server Actions are asynchronous server functions that can be called directly from Client or Server components without manually creating REST API endpoints.

8
Junior#Routing

How does File-Based Routing work in the App Router?

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.

9
Junior#CLI#Routing

How does Client-Side Navigation work in Next.js (`<Link>`, `useRouter`, `redirect`)?

Performs soft client-side navigation without full-page browser reloads • Automatically prefetches linked route data and RSC payloads in the background when the link enters the user's viewport! • useRouter(): Programmatic navigation in Client Components (router.push('/dashboard')).

10
Junior#Performance#Docker & Containers

Why should you use Next.js Image Optimization (`<Image />`) over standard `<img>`?

The next/image component automatically optimizes images for web performance: Format Optimization: Converts JPEG/PNG to modern WebP or AVIF formats based on browser support • Responsive Resizing: Generates multiple resolution variants and sets srcset so mobile devices don't download 4K desktop images.

11
JuniorCode#Routing

How do Route Handlers work in Next.js App Router (`route.ts`)?

Replaces legacy pages/api/*. Defined in app/api/.../route.ts using web-standard Request and Response APIs.

12
Junior#Performance

How does Next.js Font Optimization (`next/font`) work?

Traditional web fonts hosted on Google Fonts make external network requests, delaying text rendering and causing Cumulative Layout Shifts (CLS) when fonts swap.: next/font (Google & Local) • Downloads font files at build time and hosts them locally alongside your static assets.

13
JuniorCode#nextjs#Basic

What is Next.js Middleware (`middleware.ts`) and where does it run?

Middleware runs before an incoming request is completed, at the Edge network layer: Common Use Cases • Authentication redirects (checking session cookies before page render) • Geolocation-based routing and internationalization (i18n) • Security headers and Bot protection.

14
Junior#nextjs#Basic

What are Dynamic Route segments (`[slug]`, `[...slug]`, `[[...slug]]`)?

Single Segment (app/blog/[slug]/page.tsx): Matches /blog/react (params.slug = "react") • Catch-All (app/docs/[...slug]/page.tsx): Matches /docs/a, /docs/a/b, /docs/a/b/c (params.slug = ["a", "b", "c"]).

15
JuniorCode#nextjs#Basic

What is the `next.config.js` file and what are common configurations?

The primary configuration file for Next.js.

Part 2: Core Architecture & Implementation (Mid-Level)

15 Questions
16
Most AskedSeniorCode#System Design

How does the Next.js 4-tier Caching Architecture work?

Next.js implements four distinct caching mechanisms.

17
Most AskedSeniorCode#Forms#System Design

How do `revalidatePath` and `revalidateTag` work for on-demand cache revalidation?

Instead of waiting for a timer to expire, you purge cached data immediately after a user mutation: revalidatePath(path): Purges the Data Cache and Full Route Cache for a specific URL.

18
Senior#CLI#Components

Passing Props from Server Components to Client Components: Serialization Rules.

Server Components run on the server; Client Components run in the browser. When a Server Component passes props to a Client Component, Next.js must serialize the props to JSON across the network: Allowed Props: Strings, numbers, booleans, plain objects, arrays, Dates, BigInt, and Promises.

19
SeniorCode#SSR & Hydration#System Design

Streaming SSR with `<Suspense>`: Progressive HTML and RSC Payload.

In traditional SSR, if one database query on the page takes 3 seconds, the entire page blocks, and the user stares at a blank screen for 3 seconds. Streaming SSR: Next.js sends the instant static shell (Header, Sidebar) immediately, wraps slow components in Suspense, and streams the HTML and RSC chunks as soon as data resolves.

20
SeniorCode#Routing#System Design

Error Handling in App Router: `error.tsx`, `global-error.tsx`, and `reset()`.

error.tsx: Must be a Client Component ('use client').

21
SeniorCode#System Design

Parallel Routes (`@slot`) and Conditional Modals.

Parallel routes allow you to render one or more pages simultaneously within the same layout using named slots: Directory: app/@analytics/page.tsx and app/@team/page.tsx • Layout accepts slots as props.

22
Senior#System Design

Intercepting Routes (`(.)`, `(..)`, `(...)`) for Shareable Modals.

Allows you to intercept a route from within the current layout while displaying a modal, while direct URL visits or hard refreshes display the full dedicated page: (.) matches segments on the same level • (..) matches segments one level above • (...) matches segments from the root app directory.

23
Senior#System Design

Route Groups (`(folder)`) and Multiple Root Layouts.

Wrapping a directory name in parentheses: app/(marketing) or app/(dashboard) organizes routes logically without affecting the URL path: app/(marketing)/about/page.tsx -> /about (NOT /marketing/about).

24
Senior#System Design

Dynamic vs. Static Rendering: What triggers Dynamic Rendering?

By default, Next.js pre-renders routes statically at build time. A route automatically switches to Dynamic Rendering (rendered per-request on the server) if it uses: Dynamic functions: cookies(), headers() • Accessing searchParams prop in a page.tsx.

25
SeniorCode#State Management#Forms

Form Handling with Server Actions, `useActionState`, and `useOptimistic`.

Modern React 19 / Next.js form mutations.

26
Senior#Security & Auth#System Design

Authentication in Next.js: Auth.js (NextAuth) Session Architecture.

JWT Sessions (Edge Compatible): Stores encrypted user session tokens inside an HTTP-only cookie • Database Sessions: Stores session IDs in Redis or PostgreSQL.

27
SeniorCode#State Management#Security & Auth

Security in Server Actions: Protection Against Unauthorized Invocation.

Treat Server Actions exactly like public REST POST endpoints!: Attackers can invoke Server Actions directly by sending POST requests with arbitrary payloads • Mandatory Security Checklist • Always verify user authentication inside the action.

28
SeniorCode#Performance#System Design

SEO Optimization: Static & Dynamic Metadata API (`generateMetadata`).

Next.js provides type-safe metadata management.

29
Senior#Docker & Containers#System Design

Dynamic Open Graph (OG) Images with `@vercel/og`.

Generate customized, branded social share preview images dynamically using HTML and CSS: Runs on Edge Runtime via @vercel/og using Satori and Resvg • Renders JSX directly into high-resolution PNG images in under 50ms, eliminating pre-rendered static asset generation.

30
Senior#System Design

Turbopack vs. Webpack: Why Next.js Switched to Rust.

Webpack (Node.js/JavaScript): Interpreted JS • Turbopack (Rust) • Compiled native binary created by Webpack's author (Tobias Koppers) • Built on function-level incremental computation: only the exact function modified recomputes.

Part 3: Advanced Internals, Scale & Production Architecture (Senior / Lead)

20 Questions
31
SeniorCode#Components#Forms

Deep Dive into the React Server Component (RSC) Wire Format.

When a user navigates between pages in Next.js, the server does not send plain HTML or plain JSON. It streams the RSC Payload: A specialized streaming format.

32
Senior#SSR & Hydration#System Design

Partial Prerendering (PPR) in Next.js 15: The Ultimate Rendering Model.

Combines the speed of Static Site Generation with the power of Server-Side Rendering: At build time, Next.js generates a static HTML shell containing navigation, headers, and layouts (0ms CDN delivery) • Inside the shell, dynamic components wrapped in Suspense leave holes.

33
SeniorCode#Async & Promises#System Design

Next.js 15 Breaking Changes: Async `cookies()`, `headers()`, and `params`.

In Next.js 15: cookies(), headers(), and route params are now asynchronous Promises.

34
Senior#System Design

Optimizing Edge Runtime vs. Node.js Runtime (`export const runtime = 'edge' | 'nodejs'`).

Node.js Runtime (Default) • Full access to Node.js APIs (fs, net, crypto, native C++ binaries like Sharp) • Can connect to standard database pools • Edge Runtime (V8 Isolates).

35
Senior#SSR & Hydration#System Design

Diagnosing and Eliminating Hydration Mismatches.

Occurs when the server-rendered HTML diverges from the initial client render: Common culprits • Using typeof window !== 'undefined' to conditionally render HTML • Rendering non-deterministic values: new Date(), Math.random() • Invalid HTML nesting (e.g. Text or ``).

36
SeniorCode#Routing#System Design

Multi-Tenant Architecture in Next.js: Wildcard Subdomain Routing.

Building platforms like Shopify or Notion where each customer has subdomain.company.com: Configure wildcards in middleware.ts.

37
Most AskedSeniorCode#Docker & Containers#Kubernetes

Self-Hosting Next.js on Docker & Kubernetes: `standalone` Output.

By default, deploying Next.js requires the entire 500MB node_modules folder. In next.config.js.

38
Senior#System Design#Databases & SQL

Database Connection Pooling in Serverless & Next.js.

Serverless functions scale horizontally by creating hundreds of concurrent container instances: If 500 serverless instances each open a direct TCP connection to PostgreSQL, the database exceeds max_connections and crashes! • Mitigation • Use a connection pooler like PgBouncer or AWS RDS Proxy.

39
SeniorCode#System Design

Microfrontends and Multi-Zones in Next.js.

Running independent Next.js applications merged under a single unified domain: Main app serves / and /dashboard • Documentation team deploys a separate Next.js app serving /docs • The main app configures Rewrites.

40
Senior#Security & Auth#System Design

Content Security Policy (CSP) and Cryptographic Nonces in Next.js.

Preventing Cross-Site Scripting (XSS) in Next.js with strict CSP: In middleware.ts, generate a cryptographically random Base64 nonce per request (crypto.randomUUID()) • Attach nonce to Content-Security-Policy header: script-src 'self' 'nonce-${nonce}'.

41
Senior#State Management#System Design

Advanced Server Actions: Race Condition Mitigation and Mutex Locking.

Preventing double-submission of payments if a user double-clicks a button: Enforce UI disabling during isPending state • In the Server Action, generate an Idempotency Key or acquire a distributed atomic lock in Redis (SET lock:user_123 1 NX EX 10).

42
Senior#Memory Management#System Design

Memory Leak Debugging in Long-Lived Next.js Node Servers.

When self-hosting Next.js on Kubernetes: Common causes of memory leaks • Global arrays or cache objects that grow indefinitely in memory • Unclosed EventEmitters or setInterval timers • Retaining large request objects in closures.

43
Senior#Performance#System Design

Core Web Vitals Optimization in Next.js: Slashing LCP, INP, and CLS.

LCP (Largest Contentful Paint): Add priority to above-the-fold hero images (``) • INP (Interaction to Next Paint): Break up heavy synchronous CPU JavaScript execution using startTransition and scheduler.yield() • CLS (Cumulative Layout Shift): Always specify width and height on images; use next/font for zero-CLS font swapping.

44
Senior#System Design

Draft Mode (`draftMode().enable()`) for Headless CMS Previews.

Enables editors in Contentful/Sanity to preview unpublished draft content: CMS triggers Route Handler /api/draft?secret=TOKEN • Route Handler calls draftMode().enable(), setting a secure cookie • Subsequent page loads bypass the static Full Route Cache and fetch live draft data from the CMS API.

45
SeniorCode#System Design

Next.js Third-Parties: Loading Google Analytics and Tag Manager Without Blocking.

Using @next/third-parties.

46
SeniorCode#System Design

OpenTelemetry Integration in Next.js (`instrumentation.ts`).

Next.js supports native OpenTelemetry distributed tracing: Create instrumentation.ts in the project root.

47
Senior#Kubernetes#System Design

Zero-Downtime Blue/Green Deployment with Vercel and Edge CDNs.

How Next.js achieves instant rollbacks without flushing caches: Every deployment receives an immutable unique deployment URL (myapp-git-feat-xyz.vercel.app) • When promoted to production, edge CDN routing maps the custom domain to the new deployment.

48
SeniorCode#System Design

Dynamic Code Splitting and Dynamic Imports (`next/dynamic`).

Lazy-loading heavy client components (charts, rich-text editors, video players).

49
Senior#System Design

Managing Environment Variables in Next.js.

Server-Only Variables: Bare names (DATABASEURL, STRIPESECRET_KEY) • Client-Exposed Variables: Must be prefixed with NEXTPUBLIC (NEXTPUBLICSTRIPEPUBLISHABLEKEY) • Security Rule: Never prefix sensitive API keys or database URLs with NEXTPUBLIC!.

50
Senior#System Design

Architectural Decision Framework: When to choose Next.js vs. Remix vs. Vite SPA.

Choose Next.js App Router when: You need React Server Components (0KB JS bundle), seamless static/dynamic hybrid rendering, automated image/font • Choose Remix when: You prefer standard Web Fetch/Request APIs, nested layouts with granular data loaders, and pure progressive enhancement forms.