Skip to content
>_ StartupJobList_

Interview questions · Worked answers

Next.js interview questions and production answers

A strong Next.js answer follows one request from route match through server rendering, data access, caching, client hydration and deployment. It names which layer owns authorization and invalidation, then explains what happens when a dependency, cache or runtime fails.

For: Engineers building or operating production applications with the Next.js App Router

Guide scope and versions

Next.js 16 App Router, React Server and Client Components, Route Handlers, Server Actions, Cache Components and deployment boundaries. Pages Router behavior is not assumed. Caching and API behavior must be checked against the deployed Next.js version and platform adapter.

Question 1 of 8

Where does the Server Component and Client Component boundary sit?

App Router pages and layouts are Server Components by default. A Client Component boundary is introduced by use client, and its imported module graph becomes client code; it is for browser state, event handlers and browser APIs, not a default wrapper for the whole application.

Trace a product page with public product data and an interactive quantity picker. Fetch the product in a Server Component, then pass the minimum serializable values to a small Client Component. This keeps database access and server-only credentials out of the browser bundle while preserving the required interaction.

The boundary is transitive. Importing a server-only module from a Client Component can expose code or fail the build, and passing a secret as a prop still exposes it in the rendered payload. Keep providers low in the tree and keep server-only modules behind server-owned functions.

Follow-up: Can a Server Component import and render a Client Component?

Yes. The server can render a Client Component boundary and pass serializable props. The client module graph begins at that boundary; the server component does not turn into client code merely because it renders one.

Read the source: Next.js: Server and Client Components · React: Server Components

↑ Back to questions

Question 2 of 8

Which cache can make a user see stale or private data?

Name each cache separately: request-local memoization, persistent data caching, route output, the browser Router Cache, and any CDN or application cache. Their keys, lifetimes and invalidation paths differ, and defaults have changed between Next.js releases.

Consider a tenant-scoped dashboard. A request-local dedupe may safely share one fetch during that request, while a persistent cache keyed only by project ID could return one tenant's data to another. The cache key must include every access-relevant dimension, or the private result must not enter a shared cache.

With Next.js 16 Cache Components, caching is opt-in through use cache and cache lifetime can be assigned explicitly. Older releases and uncached APIs follow different defaults. A correct answer identifies the installed version, route, data source and cache layer before proposing revalidation.

Request trace · Worked example
Request A, tenant red: cache key [tenant=red, project=7] -> red data
Request B, tenant blue: cache key [tenant=blue, project=7] -> blue data
Unsafe key [project=7] -> one tenant can receive the other tenant's result

The key trace shows why every authorization-relevant input belongs in a shared cache key. It is a hand-worked data-flow trace, not a Next.js cache runtime test.

Non-executable cache-key trace; Next.js cache APIs and runtime behavior are covered by the cited versioned documentation.

Follow-up: Should an authenticated response use a shared cache?

Only when the cache key and invalidation policy preserve the authorization boundary. If that proof is unclear, keep the response request-scoped or uncached and measure the cost before introducing shared reuse.

Read the source: Next.js: Caching · Next.js: Caching and Revalidating (previous model)

↑ Back to questions

Question 3 of 8

How do you keep a successful mutation and its cache invalidation consistent?

Commit the authoritative write first, then invalidate or update the affected cache entries. Choose updateTag when the caller needs read-your-own-write behavior; choose revalidateTag with an explicit cache life when stale-while-revalidate is acceptable. Neither call makes a database transaction atomic with the cache.

A user edits a product and the database commit succeeds, but the process exits before invalidating the product tag. The next reader may see stale cached output. Use durable change delivery, a short bounded cache lifetime, or a repair path when that failure matters; do not claim the two systems share a transaction.

A replayed invalidation should be safe. Tag naming must follow the data ownership boundary, and broad path invalidation can cause unnecessary regeneration. When a cache refresh fails, decide whether stale content can remain available and how the failure becomes observable.

Follow-up: Does revalidateTag immediately replace every cached response?

No. Its profile controls the freshness behavior. The current recommended stale profile can serve stale data while refreshing; use updateTag for immediate read-your-own-write semantics in a Server Action when that is the requirement.

Read the source: Next.js: revalidateTag · Next.js: updateTag

↑ Back to questions

Question 4 of 8

What must a Server Action verify before changing a record?

Treat each Server Action as a remotely callable mutation endpoint. Authenticate the caller, authorize the exact record and operation at the data boundary, validate untrusted arguments, and enforce database constraints inside the write path.

A hidden button or an unguessable action identifier is not an authorization rule. A caller can submit a crafted request. Derive the actor from a trusted session, load the target through a tenant-scoped query, and perform the update under the same ownership constraint to avoid a check-then-write race.

After the commit, return only the fields the caller may see and invalidate the relevant cache. Log a stable failure category without recording tokens or sensitive form payloads. Protect duplicate submissions with an idempotency key when repeating the mutation would charge or create twice.

Follow-up: Does Next.js provide the application authorization policy?

No. The framework provides transport and execution primitives. The application must verify identity, permissions and data ownership in every mutation and server-side data path.

Read the source: Next.js: Data Security · Next.js: Mutating Data

↑ Back to questions

Question 5 of 8

How do you remove a request waterfall without hiding a required dependency?

Start independent reads together and await them at the nearest shared point. Keep dependent reads sequential, then stream slow independent subtrees behind Suspense boundaries with useful fallbacks.

A page needs a product record and a shipping estimate. If the shipping service only needs the product's postal class, fetch the product first and then request shipping. If both reads need only the route ID, start both together. Promise.all reduces latency only for independent work.

Streaming can send the shell and fast sections while a slower recommendation panel resolves. It does not make the slow dependency faster, and a fallback must not imply the final result is already complete. Define error boundaries and timeouts so one stuck service does not keep the whole response open indefinitely.

Follow-up: Should a slow child always be streamed?

Only if the shell remains useful and the user can understand the pending state. For a required permission or safety check, wait for the decision before rendering protected content.

Read the source: Next.js: Fetching Data · React: Suspense

↑ Back to questions

Question 6 of 8

When do you use a Route Handler instead of a Server Action?

Use a Server Action for an application mutation initiated by the Next.js UI when its form and cache semantics fit. Use a Route Handler when an explicit HTTP endpoint, method contract, webhook, download, or non-React client is the right interface.

A webhook needs a stable method and signature-verification path, so a Route Handler is an explicit fit. A settings form may use a Server Action, but it still needs authentication, authorization, validation and an idempotent write design.

Route Handlers do not participate in page layouts or client navigation. Avoid building the same API twice: keep one owner for the operation and have UI code call that owner through the appropriate boundary.

TypeScript · Worked example
export async function GET(request: Request) {
  const page = Number(new URL(request.url).searchParams.get("page") ?? "1");
  if (!Number.isSafeInteger(page) || page < 1 || page > 3) {
    return Response.json({ error: "page must be 1, 2, or 3" }, { status: 400 });
  }
  const ids = Array.from({ length: 2 }, (_, index) => (page - 1) * 2 + index + 1);
  return Response.json({ page, ids });
}

The route validates a query parameter and returns bounded synthetic IDs. The isolated Next.js app exercises actual HTTP responses; it does not test authentication or a real data source.

Executed in Next.js 16.4.3 / React 19.3.1 on Node 24.21.0 production build; local synthetic route responses asserted.

Follow-up: Can a Route Handler call a Server Action?

Prefer extracting the shared domain operation into a server-only function, then call it from the chosen boundary. This keeps business rules in one owner and avoids coupling HTTP handlers to action transport details.

Read the source: Next.js: Route Handlers · Next.js: Mutating Data

↑ Back to questions

Question 7 of 8

What changes when a route moves to another runtime or deployment adapter?

A route can depend on Node APIs, native modules, streaming behavior, filesystem access, connection reuse and platform-specific cache coordination. Check the runtime support matrix for every dependency and verify behavior in the actual adapter and region topology.

A package that opens a local file may work in a Node server and fail in an Edge runtime. A deployment adapter may also implement cache tags or streaming differently from the default self-hosted server. Runtime selection is part of the route contract, not only a deployment detail.

For multiple instances, verify that invalidation reaches every relevant cache and that background work survives the request lifecycle. A successful local build does not prove the platform's limits, connection pooling or failover semantics.

Follow-up: What is the minimum deployment test?

Build with the pinned production version, run the exact adapter, exercise the route's data and streaming behavior, then test an instance restart and cache invalidation across the topology the application will use.

Read the source: Next.js: Edge Runtime · Next.js: Self-Hosting

↑ Back to questions

Question 8 of 8

How should a page behave when a dependency or revalidation fails?

Separate a recoverable optional panel from data required for correctness or authorization. Use bounded timeouts, route-level error boundaries and an explicit stale-data policy; record enough telemetry to distinguish an origin outage from a cache failure.

If recommendations fail, the product page can still render the verified product and explain that recommendations are unavailable. If the tenant permission lookup fails, fail closed and do not render the protected record. The UI should not turn an infrastructure error into an empty successful result.

For cache refresh, decide whether stale content is acceptable, how long it may remain, and what triggers repair. Alert on sustained refresh failure and include route, cache tag and outcome without exposing personal data. Retry only operations with known idempotent semantics and a bounded budget.

Follow-up: When may stale content be served?

Only when the content's age and domain risk permit it. Public editorial or catalog data may tolerate bounded staleness; authorization, balances and safety-critical state generally need a fresh authoritative check.

Read the source: Next.js: Error Handling · Next.js: revalidateTag

↑ Back to questions

Salary context

Advertised salaries for these skills

These are Hacker News job posts that mention these technologies, not employee earnings or a measure of what a skill adds to pay. The amounts summarize annualized advertised minimums in approximate USD. Groups can overlap and differ in roles, locations and dates.

Next.js posts

141 posts · 141 usable advertised salary amounts

2024-06-05 to 2026-11-09

$140,000

Median advertised minimum, approximate USD/year

Middle 50%: $100,000–$160,000

Explore Next.js salaries → Browse matching job posts →
Currency and calculation basis

Approximate USD using ECB daily reference rates as of 2026-10-30. Original currencies and offer ranges remain on the source listings. These figures cover posts tagged Next.js, rather than every job in the broader technology family.

↑ Back to questions

Keep exploring