Last Minute Notes

Next.js Interview Playbook

Next.js interview rehearsal: what each level is expected to know, a 50-question bank with strong-answer checklists, predict-the-behavior puzzles, machine coding tasks, system design prompts, production scenarios, cheat sheets, common mistakes, and a 7-day study plan.

📘 Next.js Interview Playbook

The other pages teach the material. This page is for rehearsal: a question bank with what a strong answer contains, predict-the-behavior puzzles, machine coding tasks that come up in live rounds, design prompts, and a study plan.

Table of Contents

  1. What Interviewers Look For
  2. Question Bank
  3. Predict the Behavior
  4. Machine Coding Tasks
  5. System Design Prompts
  6. Production Scenarios
  7. Cheat Sheets
  8. Common Mistakes
  9. Study Plan

1. What Interviewers Look For

LevelExpected
JuniorReact fundamentals, App Router file conventions, Link and navigation, dynamic routes, layouts, next/image, environment variables, fetching in Server Components, basic forms
MidServer vs Client Components and the boundary, rendering modes, caching and revalidation, Server Actions with validation, loading/error UI, metadata and SEO, auth basics, Core Web Vitals, testing with Playwright
SeniorRSC payload and streaming internals, Cache Components and PPR, caching layers and debugging stale data, security model (DAL, CSRF, CSP), performance budgets, multi-instance deployments, observability, upgrade strategy
Staff / platformArchitecture for many teams (monorepos, design systems, micro-frontends and multi-zones), build and deploy infrastructure, cache handler design, migration from Pages Router or an SPA, performance and reliability governance

Signals that raise your rating:

  • Always saying where code runs (build, server request, browser) and what is cached.
  • Naming the trade-off: static speed vs freshness, bundle size vs interactivity, convenience vs control.
  • Knowing what is current (async request APIs, proxy.ts, Turbopack default, "use cache" and Cache Components, React 19.2 features) and which advice is from the older caching model.
  • Treating Server Actions and Route Handlers as public endpoints that need authn, authz, and validation.
  • Proposing how you would measure and verify: build output table, bundle analyzer, RUM, Playwright against a production build.

2. Question Bank

2.1 Fundamentals (10)

#QuestionStrong answer includesRead
1What is Next.js and why use it?Full-stack React framework; SSR/SSG/streaming, routing, optimizations, API layer; trade-offsFundamentals
2App Router vs Pages Router?Server Components, nested layouts, streaming, Actions vs data functions; Pages in maintenanceFundamentals
3layout vs template vs page?Persistence vs remount vs unique UIFundamentals
4Special files in a route segment?loading, error, not-found, route, default, nesting orderFundamentals
5How do env vars work?NEXT_PUBLIC_ inlined at build, others server-only, server-only packageFundamentals
6How does next/image help?Resize, formats, lazy load, dimensions prevent CLS, priority, sizes, remotePatternsFundamentals
7How does next/font work?Self-hosted at build, no runtime request, fallback metrics, no CLSFundamentals
8How do you handle SEO?Metadata API, generateMetadata, sitemap, canonical, OG images, server HTMLFundamentals
9Why use Link instead of <a>?Client navigation, prefetch, layout persistenceFundamentals
10Next.js vs Vite SPA vs Remix vs Astro?Use cases, SEO, server runtime, data modelFundamentals

2.2 Rendering and Server Components (10)

#QuestionStrong answer includesRead
11CSR vs SSR vs SSG vs ISR?Where and when HTML is made, freshness, cost, examplesRendering
12What is a React Server Component?Server-only, no client JS, async, RSC payload; not the same as SSRRendering
13What does 'use client' do?Module boundary, client bundle entry, still pre-rendered on the serverRendering
14Can a Client Component render a Server Component?Only via children/props passed from a server parentRendering
15What can be passed from server to client?Serializable values, Promises, JSX, Server Actions; no functions/classesRendering
16What makes a route dynamic?cookies, headers, searchParams, uncached data, force-dynamicRendering
17How does streaming work?Suspense boundaries, shell first, loading.tsx, independent chunksRendering
18What causes hydration errors?Server/client markup mismatch, dates, window, invalid nestingRendering
19What is Partial Prerendering?Static shell plus dynamic holes in one response; Cache ComponentsRendering
20Node vs Edge runtime?API support, cold start, defaults, when to use eachRendering

2.3 Routing and Data (10)

#QuestionStrong answer includesRead
21Dynamic, catch-all, optional catch-all?[x], [...x], [[...x]], precedenceRouting
22Why are params async?Reading them can make rendering dynamic; Promise allows prerenderRouting
23Parallel and intercepting routes?Slots, default.tsx, modal with its own URLRouting
24generateStaticParams and dynamicParams?Build-time paths, on-demand fallback, 404 modeRouting
25Redirect vs rewrite, and where to define them?Config, proxy.ts, redirect()Routing
26How do you fetch data and avoid waterfalls?Server Components, Promise.all, Suspense per section, preloadData Fetching
27Explain the caching layersRequest memoization, Data Cache, Full Route Cache, Router CacheData Fetching
28What changed in caching from 14 to 15 to 16?Default cache removal; explicit "use cache"Data Fetching
29revalidateTag vs updateTag vs revalidatePath?SWR semantics, read-your-writes, path-basedData Fetching
30React.cache vs "use cache"?Per-render dedupe vs cross-request cacheData Fetching

2.4 Mutations, Security, and Auth (10)

#QuestionStrong answer includesRead
31What is a Server Action?'use server', POST endpoint, serializable args, auto UI updateActions
32Action vs Route Handler?Mutations for own UI vs public HTTP APIActions
33useActionState, useFormStatus, useOptimistic?State, pending, rollback semanticsActions
34How do you validate and report errors?Zod server-side, return typed errors, throw only unexpectedActions
35Are Server Actions secure by default?No, public endpoints; authn, authz, validation insideActions
36What is proxy.ts for?Early redirects/rewrites/headers; not the security boundaryAuth
37Cookie sessions vs JWT?Revocation, size, flags HttpOnly/Secure/SameSiteAuth
38What is the Data Access Layer pattern?Server-only module, session check, authorization, DTOsAuth
39How do you protect against CSRF and XSS?SameSite, origin check, escaping, sanitize, CSPAuth
40How do you set up a strict CSP?Nonce in proxy, strict-dynamic, dynamic rendering trade-offAuth

2.5 Performance and Operations (10)

#QuestionStrong answer includesRead
41Improve LCP?TTFB, hero priority, sizes, fonts, static/streamed HTMLPerformance
42Improve INP?Less hydration, transitions, long tasks, third-party scriptsPerformance
43Reduce bundle size?Server Components, dynamic, analyzer, replace libraries, budgetPerformance
44Third-party scripts?next/script strategies, @next/third-parties, facadesPerformance
45How do you test an app with Server Components?Extract logic, RTL for clients, Playwright for server outputTesting and Deployment
46Deployment options?Vercel, Node, Docker standalone, static export, adaptersTesting and Deployment
47ISR in multiple instances?Shared cacheHandler, CDN purge, per-instance defaultTesting and Deployment
48Observability setup?instrumentation.ts, OTel, Sentry, RUM, request ids, source mapsTesting and Deployment
49Handling deployment skew?Deployment id, skew protection, backward-compatible DBTesting and Deployment
50Migrate a CRA/Pages app to App Router?Incremental, coexistence, route by route, codemods, test coverage firstFundamentals

3. Predict the Behavior

3.1

// app/page.tsx  (no directive)
import { useState } from 'react';

export default function Page() {
  const [n, setN] = useState(0);
  return <button onClick={() => setN(n + 1)}>{n}</button>;
}

Answer: build error: useState and event handlers are not allowed in Server Components. Add 'use client' at the top, or better, extract the button into a small Client Component and keep the page on the server.

3.2

// app/blog/[slug]/page.tsx
export default function Page({ params }: { params: { slug: string } }) {
  return <h1>{params.slug}</h1>;
}

Answer: in current versions params is a Promise, so params.slug is undefined (and TypeScript/dev warnings flag the sync access). Make the component async and const { slug } = await params.

3.3

export default async function Page() {
  const user = await getUser();          // 300 ms
  const posts = await getPosts();        // 300 ms
  return <Dashboard user={user} posts={posts} />;
}

Answer: about 600 ms because the awaits are sequential even though they are independent. Use Promise.all([getUser(), getPosts()]) (about 300 ms), or split into two components under separate Suspense boundaries.

3.4

'use cache';
export default async function Page() {
  const theme = (await cookies()).get('theme')?.value;
  return <Themed theme={theme} />;
}

Answer: error: request-specific APIs such as cookies() cannot be used inside a cached scope, because the cached result would be shared between users. Read the cookie in an uncached parent and pass it as an argument to a "use cache" child, or cache nothing here.

3.5

// Server Component
<Button onClick={() => console.log('hi')} />   // Button is a Client Component

Answer: error: functions cannot be passed from a Server Component to a Client Component, since they are not serializable. Define the handler inside the Client Component, or pass a Server Action (marked 'use server').

3.6

'use server';
export async function save(formData: FormData) {
  try {
    await db.save(formData);
    redirect('/done');
  } catch (e) {
    return { error: 'failed' };
  }
}

Answer: the user is never redirected on success. redirect() throws a special error, the catch swallows it, and the action returns { error: 'failed' }. Call redirect outside the try/catch.

3.7

'use client';
export function Clock() {
  return <p>{new Date().toLocaleTimeString()}</p>;
}

Answer: hydration mismatch warning. The server renders one time and the client renders another when hydrating. Render a stable value first and update in useEffect, or render the time only after mount.

3.8

// app/dashboard/layout.tsx
export default async function Layout({ children }: { children: React.ReactNode }) {
  const session = await getSession();
  if (!session) redirect('/login');
  return <>{children}</>;
}

Answer: not sufficient as the only protection. Layouts do not re-render when navigating between child pages and pages can be rendered independently, so a check here can be skipped. Verify authorization in each page and in the data access layer, Actions, and Route Handlers that touch the data.

3.9

// app/api/items/route.ts
export async function GET() {
  return Response.json(await db.item.findMany());
}

Answer: in current versions this GET is not cached; it runs on every request. In Next 13/14 it was cached by default at build time and returned stale data. Opt in to caching explicitly with "use cache" or dynamic = 'force-static' and revalidate with a tag.

3.10

// Server Action
export async function addTodo(formData: FormData) {
  'use server';
  await db.todo.create({ data: { title: String(formData.get('title')) } });
}
// UI still shows the old list after submit

Answer: the mutation worked but no cache was invalidated, so the list (cached or Router Cache) is stale. Call revalidatePath('/todos'), updateTag('todos'), or refresh() at the end of the action.

3.11

const { data } = useSearchParams();   // inside a statically rendered page, no Suspense

Answer: useSearchParams returns a URLSearchParams, not { data }, and, more importantly for builds, using it without a Suspense boundary in a static page makes next build fail with a "missing suspense boundary" error. Wrap the component in <Suspense>.

3.12

<Image src="https://cdn.example.com/a.jpg" alt="" />

Answer: error: missing width/height (or fill) for a remote image, and the host must be allowed in images.remotePatterns. Provide dimensions or fill with a sized parent, and configure the host.


4. Machine Coding Tasks

Typical 60 to 90 minute live tasks, with what to show:

TaskShow
Blog with ISRgenerateStaticParams, generateMetadata, notFound(), tag revalidation webhook, sitemap, next/image cover
Todo app with Server ActionsForm + useActionState, Zod validation, useOptimistic, revalidation, pending UI, works without JS
Auth flowLogin/logout actions, HttpOnly session cookie, proxy.ts redirect, DAL with verifySession, protected page, error states
Product listing with filtersSearch params state, server-side filtering, pagination, Suspense skeleton, shareable URLs, debounced input with router.replace
Dashboard with streamingIndependent Suspense widgets, parallel fetching, per-widget error boundaries, loading.tsx
Infinite scroll feedServer-rendered first page, Client Component with TanStack Query useInfiniteQuery and a Route Handler, IntersectionObserver
Photo gallery with modal routeParallel @modal slot and intercepting route, direct URL renders full page, router.back() close
Checkout / form wizardMulti-step form state, server-side validation per step, persistence in cookie or DB, optimistic UI, idempotent submit
Webhook receiverRaw body signature verification, idempotency key, quick 2xx, async processing, tests
Search with autocompleteDebounce, cancel stale requests, Route Handler, keyboard accessibility, useDeferredValue

Structure your solution like production code: typed props, schema validation shared by client and server, a data access module, a short note on caching and revalidation, and what you would test.


5. System Design Prompts

Frame every answer with: requirements (SEO? personalization? scale? freshness?), rendering strategy per page type, data flow and caching, auth and security, performance budget, deployment, and monitoring.

PromptKey points
Design an e-commerce storefrontStatic product pages with tag-based revalidation from inventory/CMS, PPR for cart and price personalization, search via dedicated service, next/image and CDN, checkout server-side with idempotency, A/B tests in proxy.ts, Core Web Vitals budget
Design a news/media siteISR or use cache with short lifetimes, breaking-news purge by tag, CDN stale-while-revalidate, AMP-free fast pages, ad/script strategy for INP, sitemap/news metadata, preview mode for editors
Design a SaaS dashboard (multi-tenant)Subdomain rewrite to tenant, session + RBAC in a DAL, tenant scoping on every query and row-level security, streaming widgets, client query cache for live data, audit logs
Design a docs siteStatic generation of MDX, search index at build, versioned routes, generateStaticParams, on-demand revalidation from the docs repo, i18n
Design a social feedServer-rendered first page for SEO, cursor-paginated Route Handler for infinite scroll, optimistic likes with Actions, real-time via SSE/WebSocket service, image CDN, cache keyed by user
Design the platform for 20 teams on one Next.js codebaseMonorepo (Turborepo), shared design system, feature folders, ownership via CODEOWNERS, multi-zones for independent deploys, bundle budgets and lint rules in CI, preview environments
Migrate a large Pages Router appIncremental coexistence, move leaf routes first, shared layouts, replace getServerSideProps with Server Components, regression tests first, measure bundle and vitals along the way

See Frontend System Design for the general framework.


6. Production Scenarios

ScenarioStrong answer
Users see old content after publishingCheck webhook delivery, tag names match, shared cache across instances, CDN caching HTML, test with a production build; use updateTag for the actor, tag revalidation for others
Page is slow only for logged-in usersDynamic rendering (cookies) bypasses static; add Suspense around personalized parts, cache shared data, parallelize fetches, check DB and region
TTFB spiked after a deployCold caches and empty ISR store, new instances; warm critical routes, shared cache handler, check dynamic API accidentally added in a layout
Memory grows until the container restartsUnbounded module-level caches, per-request data stored globally, large closures; heap snapshot, bound caches, check sharp and image optimizer load
Hydration errors in production onlyLocale/time zone or extension differences, content from CMS with invalid HTML; reproduce with the same data, use suppressHydrationWarning narrowly, fix markup
Security scan flags Server ActionsMissing auth/authorization inside actions, no rate limit, verbose errors; add DAL checks, validation, throttling, generic messages
Build times exceed 30 minutesToo many generateStaticParams paths, slow data source; prerender top N, on-demand for the rest, cache fetches, CI .next/cache
CSP breaks the siteInline scripts without nonce, third-party domains missing; report-only first, nonce via proxy.ts, allowlist reviewed domains
Old clients error after deployDeployment skew; keep prior assets available, skew protection, backward-compatible APIs and Actions
SEO traffic droppedContent rendered client-side only, missing metadata or canonical, broken sitemap, noindex from staging env var; inspect the rendered HTML, Search Console, and robots

7. Cheat Sheets

7.1 Server or Client Component?

NeedUse
Fetch data, access DB or secretsServer
Static content, large libraries (markdown)Server
useState, useEffect, event handlersClient
Browser APIs (localStorage, window)Client
Context providersClient wrapper, children stay server
Third-party widget needing hooksClient wrapper file

7.2 Which data approach?

SituationUse
Initial page dataawait in Server Component
Shared across components in one renderReact.cache
Shared across requests"use cache" with cacheLife and cacheTag
Mutation from your UIServer Action then updateTag/revalidateTag
Public API, webhook, streamingRoute Handler
Live or polling dataClient library (TanStack Query)

7.3 Which revalidation?

NeedUse
Author must see their own change instantlyupdateTag(tag)
Everyone else eventuallyrevalidateTag(tag, 'max')
A whole routerevalidatePath(path)
Refresh uncached data in placerefresh() / router.refresh()
Time-basedcacheLife or revalidate

7.4 Version facts worth knowing

FactValue
App Router stable13.4
Server Actions stable14
fetch/GET handlers uncached by default, async request APIs, React 19, Turbopack dev stable15
Turbopack default for dev and build16
middleware.ts renamed to proxy.ts (Node runtime)16
Cache Components, "use cache", updateTag, refresh()16
next lint removed16
React Compiler supportStable in 16 (opt in)
Node.js minimum20.9+

8. Common Mistakes

MistakeBetter
Marking everything 'use client'Server by default, small interactive leaves
Fetching in useEffect for page dataFetch in a Server Component
Calling your own Route Handler from a Server ComponentCall the underlying function directly
Auth only in proxy.ts or a layoutEnforce in the DAL, Actions, and Route Handlers
Forgetting revalidation after a mutationupdateTag/revalidateTag/revalidatePath in the action
redirect() inside try/catchCall it outside, or rethrow
Putting secrets in NEXT_PUBLIC_Server-only variables
Passing whole DB rows to Client ComponentsPass minimal DTOs
Describing caching of Next 13 as currentExplain the shift to explicit caching
Assuming a page is staticRead the next build route table
Testing only in dev modeProduction build for performance, caching, and E2E
Ignoring Core Web VitalsName the metric, tool, and fix

9. Study Plan

DayFocusDo
1FundamentalsCreate an app; build layouts, a dynamic route, loading/error, metadata, next/image; read next build output
2Rendering and Server ComponentsExplain RSC vs SSR aloud in 3 minutes; build a Server page with a Client island; trigger and fix a hydration mismatch
3RoutingDynamic + catch-all routes, generateStaticParams, a modal with parallel and intercepting routes
4Data Fetching and CachingTurn on Cache Components; use cache with tags; remove a waterfall; draw the cache layers from memory
5Server Actions and AuthForm with useActionState and Zod; session cookie, proxy.ts, DAL; a Stripe-style webhook handler
6Performance and Testing and DeploymentRun the bundle analyzer and Lighthouse; write one Playwright test; build a standalone Docker image
7This playbookAnswer the question bank aloud, do one machine coding task and one system design prompt timed

On this page