23 role-specific questions
Next.js Developer Interview Questions & Answers
Next.js roles test whether you can choose the right rendering strategy for each page, split work between Server and Client Components, and reason about caching, data fetching and authentication in a full-stack React framework.
Free, no sign-up. 110 questions in this role's practice pool, including behavioural, HR and situational questions.
Next.js interview questions
The App Router, Server and Client Components, rendering strategies, caching, route handlers and middleware.
1.
Explain Server Components and Client Components in the Next.js App Router. How do you decide which to use?
IntermediateTechnicalPractise this question and get feedbackWhat the interviewer is evaluating
Whether you can split an app sensibly between server and client.
Key points a strong answer covers
- Server by default. In the App Router, components are Server Components by default.
- 'use client' boundary.
'use client'marks the entry to client code; everything it imports becomes client code. - When client. Use Client Components for state, effects, event handlers and browser APIs.
- Keep client islands small. Push 'use client' to the leaves and pass Server Components as children.
- Serialisable props. Props crossing the boundary must be serialisable — no functions (except Server Actions).
Suggested answer structure
- Define it in one sentence.
- Explain how it works underneath.
- Give a practical example from code or a project.
- Close with a trade-off, pitfall or when you'd use it.
Common mistakes
- Adding 'use client' to the root layout.
- Importing server-only code (secrets, DB clients) into a client file.
Likely follow-up questions
- How can a Client Component render a Server Component?
- What does the
server-onlypackage protect against?
Example strong answer
In the App Router everything is a Server Component unless a file starts with
'use client'. Server Components render on the server, can be async, fetch data directly and ship no JavaScript. I switch to a Client Component only when I need state, effects, event handlers or browser APIs — a search box, a modal, a chart. The directive marks a boundary: that file and everything it imports goes to the client, so I push it as far down as possible — a page stays a Server Component and renders a small<AddToCartButton>client island. A Client Component can still show server-rendered content passed aschildren. Props across the boundary must be serialisable, and I guard server code with theserver-onlypackage.2.
How does server-side rendering work, and what is hydration?
BeginnerTechnicalPractise this question and get feedbackWhat the interviewer is evaluating
Fundamentals behind performance and hydration bugs.
Key points a strong answer covers
- HTML rendered on the server. The server renders the page to HTML so the user sees content before JavaScript loads.
- Hydration. In the browser React hydrates: attaches event handlers to the existing HTML to make it interactive.
- Benefits. Better first paint and crawlable content.
- Hydration mismatch. Server and client output must match — dates, random values and window checks cause mismatches.
Suggested answer structure
- Define it in one sentence.
- Explain how it works underneath.
- Give a practical example from code or a project.
- Close with a trade-off, pitfall or when you'd use it.
Common mistakes
- Thinking SSR means the page needs no JavaScript.
- Reading
windowduring render, causing mismatches.
Likely follow-up questions
- How would you fix a hydration mismatch caused by a timestamp?
- What is streaming SSR?
Example strong answer
With SSR the server runs the React components for a request and sends complete HTML, so the browser can show content immediately and crawlers see real text. Then the JavaScript loads and React hydrates the page: it walks the existing HTML and attaches event handlers and state, making it interactive rather than re-creating the DOM. For that to work the first client render has to produce the same output as the server. Hydration mismatches usually come from things like
new Date(), random IDs, locale formatting or checkingwindowduring render; I move those into an effect, useuseId, or format on the server. With the App Router, Suspense also lets the server stream HTML in chunks.3.
Explain static generation, dynamic rendering and incremental static regeneration (ISR).
IntermediateTechnicalPractise this question and get feedbackWhat the interviewer is evaluating
Choosing a rendering strategy per page.
Key points a strong answer covers
- Static at build. Static pages are rendered at build time and served from a CDN.
- Dynamic per request. Dynamic rendering runs per request — needed for cookies, headers or personalised data.
- ISR / revalidate. ISR serves a cached page and regenerates it in the background after a time or on demand.
- Choosing. Choose by how fresh and how personalised the data must be.
Suggested answer structure
- Define it in one sentence.
- Explain how it works underneath.
- Give a practical example from code or a project.
- Close with a trade-off, pitfall or when you'd use it.
Common mistakes
- Making every page dynamic by reading cookies in the root layout.
- Not knowing on-demand revalidation exists.
Likely follow-up questions
- What makes a route dynamic automatically?
- How would you update a product page instantly after an edit in the CMS?
Example strong answer
Static generation renders a page at build time, so it's just a file on the CDN — fastest and cheapest, ideal for marketing pages and blog posts;
generateStaticParamspre-builds dynamic routes like/blog/[slug]. Dynamic rendering runs on every request, which you need when the output depends on cookies, headers or search params — a dashboard, for instance. Reading those APIs opts a route into dynamic rendering. ISR sits in between: the page is served from cache and regenerated in the background after a revalidate period, or on demand withrevalidatePathorrevalidateTag— so a CMS webhook can refresh a product page the moment it's edited. I choose per route based on freshness and personalisation.4.
How do you handle caching in Next.js?
AdvancedTechnicalPractise this question and get feedbackWhat the interviewer is evaluating
Understanding of the different cache layers and how to invalidate them.
Key points a strong answer covers
- Multiple layers. There are several layers: request memoisation, data cache, full route cache, client router cache, plus the CDN.
- fetch / cache options. fetch options or segment config control caching; defaults have changed between versions, so be explicit.
- Invalidation. Invalidate with
revalidatePath/revalidateTagafter mutations. - Personalised data. Never cache personalised responses publicly.
- Verify. Check build output and response headers to verify what's actually cached.
Suggested answer structure
- Define it in one sentence.
- Explain how it works underneath.
- Give a practical example from code or a project.
- Close with a trade-off, pitfall or when you'd use it.
Common mistakes
- Assuming the defaults without checking the Next.js version.
- Caching a page that shows the logged-in user's data.
Likely follow-up questions
- What's the difference between
revalidatePathandrevalidateTag? - How do you cache a database query that doesn't use fetch?
Example strong answer
I think of it as layers: per-request memoisation of identical fetches, the data cache for fetch results, the full route cache for rendered static pages, the client-side router cache, and the CDN in front. Caching defaults have changed between Next.js versions, so I'm explicit:
cache: 'force-cache'ornext: { revalidate: 3600, tags: ['products'] }for shared data,no-storefor anything per user. After a mutation — say a Server Action that updates a product — I callrevalidateTag('products')so every page using that data refreshes. For non-fetch data like a DB query I use the framework's cache function with tags. Personalised data is never cached publicly. And I verify with the build output and response headers rather than assuming.5.
Explain route handlers and middleware in Next.js. What would you use each for?
IntermediateTechnicalPractise this question and get feedbackWhat the interviewer is evaluating
Server-side building blocks and their limits.
Key points a strong answer covers
- Route handlers = API endpoints. Route handlers (
app/api/x/route.ts) export GET/POST functions using Web Request/Response. - Uses for handlers. Webhooks, endpoints for other clients, OAuth callbacks.
- Middleware runs before routing. Middleware runs before a request is handled, on matched paths.
- Uses for middleware. Redirects, rewrites, auth checks, locale detection, headers.
- Keep middleware light. It runs on every matched request, so keep it fast — no heavy DB work.
Suggested answer structure
- Define it in one sentence.
- Explain how it works underneath.
- Give a practical example from code or a project.
- Close with a trade-off, pitfall or when you'd use it.
Common mistakes
- Using route handlers just to fetch data for your own Server Components.
- Doing full authorisation only in middleware.
Likely follow-up questions
- Why shouldn't middleware be your only authorisation check?
- When would you use a Server Action instead of a route handler?
Example strong answer
Route handlers are the App Router's API endpoints: a
route.tsexportingGET,POSTand so on, using standard Request and Response objects. I use them for things that need a URL — webhooks from Stripe, OAuth callbacks, or an API consumed by a mobile app. For my own pages I don't need them: Server Components can fetch data directly, and mutations can use Server Actions. Middleware runs before a request reaches a route, on paths chosen by a matcher, so it's good for redirects, rewrites, locale detection, setting headers and a quick check that a session cookie exists. It runs on every matched request, so I keep it light, and I still check permissions where the data is accessed.- Route handlers = API endpoints. Route handlers (
6.
What are Server Actions, and what do you need to be careful about?
IntermediateTechnicalPractise this question and get feedbackWhat the interviewer is evaluating
Safe use of server mutations.
Key points a strong answer covers
- Server functions called from the client. Server Actions are async functions marked 'use server' that the client can call, e.g. from a form.
- Progressive enhancement. They work with
<form action>— even before JavaScript loads. - Treat as public endpoints. Each action is effectively a public endpoint — validate input and check auth inside it.
- Revalidate after. Revalidate or redirect after the mutation so the UI updates.
Suggested answer structure
- Define it in one sentence.
- Explain how it works underneath.
- Give a practical example from code or a project.
- Close with a trade-off, pitfall or when you'd use it.
Common mistakes
- Trusting the input because “only my form calls it”.
- Forgetting to revalidate, so the page shows stale data.
Likely follow-up questions
- How would you show a pending state for a form using a Server Action?
- How do you return validation errors to the form?
Example strong answer
Server Actions are async functions marked
'use server'that run on the server but can be called from the client — most simply as a form'saction, which works even before JavaScript loads. They're great for mutations like creating a post: no separate API route, and the action can callrevalidatePathorredirectwhen it's done. The big caution is that each action is effectively a public HTTP endpoint, so I validate the input with a schema and check authentication and authorisation inside the action itself, never relying on the UI. For UX I useuseActionStateto return validation errors anduseFormStatusfor the pending state.7.
How does Next.js help with images and fonts, and why does it matter?
BeginnerTechnicalPractise this question and get feedbackWhat the interviewer is evaluating
Core Web Vitals awareness.
Key points a strong answer covers
- next/image. next/image serves resized, modern-format, lazy-loaded images.
- Layout shift. Width/height or a fill container reserve space and prevent layout shift.
- Priority / LCP. Mark the hero image as priority so the LCP image isn't lazy-loaded.
- next/font. next/font self-hosts fonts with no layout shift from swapping.
Suggested answer structure
- Define it in one sentence.
- Explain how it works underneath.
- Give a practical example from code or a project.
- Close with a trade-off, pitfall or when you'd use it.
Common mistakes
- Lazy-loading the hero (LCP) image.
- Using huge original images for thumbnails.
Likely follow-up questions
- Which Core Web Vital does the hero image affect most?
- How does
sizeschange which image the browser downloads?
Example strong answer
Images are usually the biggest bytes on a page and the LCP element, so
next/imagematters: it serves resized images in modern formats like WebP or AVIF, lazy-loads below-the-fold images, and requires dimensions or a sized container so space is reserved and there's no layout shift. Thesizesattribute tells the browser which width to fetch on each screen. For the hero image I set priority loading so it isn't lazy-loaded.next/fontdownloads fonts at build time and self-hosts them, adjusts fallback metrics to avoid layout shift, and removes a request to a third-party font server — which helps privacy too.8.
How do you handle SEO in a Next.js app?
BeginnerTechnicalPractise this question and get feedbackWhat the interviewer is evaluating
Practical SEO for server-rendered React.
Key points a strong answer covers
- Metadata API. Use the Metadata API / generateMetadata for titles, descriptions and Open Graph.
- Rendered HTML. Server or static rendering puts real content in the HTML for crawlers.
- Canonical / sitemap / robots. Canonical URLs, sitemap.ts and robots.ts.
- Structured data / performance. JSON-LD structured data, and good Core Web Vitals.
Suggested answer structure
- Define it in one sentence.
- Explain how it works underneath.
- Give a practical example from code or a project.
- Close with a trade-off, pitfall or when you'd use it.
Common mistakes
- Rendering the main content only on the client.
- Duplicate titles across pages.
Likely follow-up questions
- How would you generate unique metadata for 10,000 product pages?
- What's a canonical URL for?
Example strong answer
Next.js gives a strong base because pages are server- or statically rendered, so the content is in the HTML crawlers receive — I make sure important content isn't only rendered client-side. I set titles, descriptions and Open Graph tags through the Metadata API, using
generateMetadatafor dynamic pages so each product gets a unique title from its data. I add canonical URLs to avoid duplicates from query strings, generatesitemap.tsandrobots.ts, and include JSON-LD structured data where it fits, like Product or Article. Performance matters too, so I watch Core Web Vitals.9.
How would you implement authentication in a Next.js App Router application?
AdvancedTechnicalPractise this question and get feedbackWhat the interviewer is evaluating
Security across server, middleware and client.
Key points a strong answer covers
- Session storage. Store the session in an httpOnly, Secure, SameSite cookie.
- Library / provider. Use a proven library or provider rather than rolling your own.
- Check where data is read. Verify the session where data is accessed: in Server Components, actions and handlers.
- Middleware for redirects. Middleware can redirect logged-out users early, as an optimisation, not the only check.
- Authorisation. Check permissions, not just that someone is logged in.
Suggested answer structure
- Define it in one sentence.
- Explain how it works underneath.
- Give a practical example from code or a project.
- Close with a trade-off, pitfall or when you'd use it.
Common mistakes
- Protecting pages only in middleware or only on the client.
- Storing tokens in localStorage.
Likely follow-up questions
- Why is client-side route protection not enough?
- How do you protect a Server Action?
Example strong answer
I'd use a proven library or provider — Auth.js, Clerk, or similar — rather than writing session handling myself. The session lives in an httpOnly, Secure, SameSite cookie, never in localStorage. Middleware can do a cheap check and redirect signed-out users away from
/dashboard, but that's an optimisation; the real check happens where data is read and changed — a small data-access layer that verifies the session and the user's permissions, used by Server Components, Server Actions and route handlers alike. Client-side checks only shape the UI. And I check authorisation, not just authentication: the user must own the invoice they're editing.10.
How do loading.tsx, error.tsx and not-found work in the App Router?
IntermediateTechnicalPractise this question and get feedbackWhat the interviewer is evaluating
Knowledge of the App Router file conventions.
Key points a strong answer covers
- loading = Suspense boundary. loading.tsx wraps the route segment in a Suspense boundary with that fallback.
- error = error boundary. error.tsx is a Client Component error boundary for the segment, with a reset function.
- not-found. Calling
notFound()renders the nearest not-found.tsx with a 404. - Nesting / layouts. They apply per segment; layouts above stay interactive. global-error covers the root layout.
Suggested answer structure
- Define it in one sentence.
- Explain how it works underneath.
- Give a practical example from code or a project.
- Close with a trade-off, pitfall or when you'd use it.
Common mistakes
- Not knowing error.tsx must be a Client Component.
- Expecting error.tsx to catch errors in its own layout.
Likely follow-up questions
- Why doesn't error.tsx catch errors thrown in the layout of the same segment?
- When would you use a manual Suspense boundary instead of loading.tsx?
Example strong answer
They're file conventions that wrap each route segment.
loading.tsxbecomes the fallback of a Suspense boundary around the segment's page, so navigation shows a skeleton instantly while the server streams the content.error.tsxis an error boundary — it must be a Client Component — that catches errors in that segment and receiveserrorand aresetfunction to retry; the layouts above it stay interactive. Because it sits inside the segment's layout, an error in that layout bubbles to the parent's boundary, andglobal-error.tsxcovers the root layout. CallingnotFound()in a page renders the nearestnot-found.tsxwith a 404 status — I use that when a slug doesn't exist.
React interview questions
Rendering, reconciliation, hooks, state management and performance — from the questions every React interview asks to senior-level depth.
1.
Explain the React rendering process. What happens when state changes?
IntermediateTechnicalPractise this question and get feedbackWhat the interviewer is evaluating
Whether you understand render vs commit, which underpins performance work.
Key points a strong answer covers
- Triggers. A render is triggered by a state update, a parent re-render or a context change.
- Render phase. React calls your components to get new elements — this should be pure, with no side effects.
- Reconciliation / diff. It compares the new tree with the previous one to work out what changed.
- Commit phase. In the commit phase React applies the minimal DOM changes, then runs effects.
- Batching. Multiple state updates in one event are batched into one render.
Suggested answer structure
- Define it in one sentence.
- Explain how it works underneath.
- Give a practical example from code or a project.
- Close with a trade-off, pitfall or when you'd use it.
Common mistakes
- Saying a re-render always updates the DOM.
- Putting side effects in the render body.
Likely follow-up questions
- Why must components be pure during render?
- When do
useLayoutEffectanduseEffectrun relative to paint?
Example strong answer
When state changes, React schedules a render of that component — and by default its children. In the render phase React calls the component functions to produce a new tree of elements; that work must be pure, because React may call it more than once or throw it away. It then reconciles: compares the new tree with the previous one to find what actually changed. In the commit phase it applies only those changes to the DOM, runs layout effects, lets the browser paint, and then runs
useEffects. Updates inside one event are batched into a single render. So a re-render doesn't necessarily touch the DOM — it only does if the output differs.2.
How does React reconciliation work, and why do list keys matter?
IntermediateTechnicalPractise this question and get feedbackWhat the interviewer is evaluating
Understanding of the diffing heuristics and the bugs that bad keys cause.
Key points a strong answer covers
- Heuristic diff. React uses heuristics to diff in O(n) rather than a full tree comparison.
- Type changes remount. If an element's type changes, React throws away that subtree and mounts a new one.
- Keys identify items. Keys tell React which list item is which between renders.
- Index key bugs. Index keys attach state to the wrong item when the list is reordered or items are inserted.
Suggested answer structure
- Define it in one sentence.
- Explain how it works underneath.
- Give a practical example from code or a project.
- Close with a trade-off, pitfall or when you'd use it.
Common mistakes
- Using
Math.random()as a key. - Thinking keys are only about silencing the console warning.
Likely follow-up questions
- How can you use a key to reset a component's state on purpose?
- What happens if two siblings share a key?
Example strong answer
Reconciliation is how React decides what changed between two renders. A full tree diff would be too slow, so React assumes two things: elements of a different type produce different trees — so if a
<div>becomes a<section>, or one component becomes another, the old subtree is unmounted and a new one mounted — and keys identify children in a list. With stable keys from your data, React can match items even when they move, keeping their state and DOM. With index keys, inserting at the top shifts every key, so state like a text input's value ends up on the wrong row. You can also change a key deliberately to reset a component, like<Profile key={userId} />.3.
What is the difference between useMemo and useCallback? When are they worth using?
IntermediateTechnicalPractise this question and get feedbackWhat the interviewer is evaluating
Whether you optimise deliberately rather than by habit.
Key points a strong answer covers
- useMemo caches a value.
useMemocaches the result of a calculation between renders. - useCallback caches a function.
useCallbackcaches a function's identity —useCallback(fn, deps)isuseMemo(() => fn, deps). - Dependencies. Both recompute only when their dependencies change.
- When worth it. Worth it for expensive work, props to memoised children, or effect dependencies — measure first.
Suggested answer structure
- Define it in one sentence.
- Explain how it works underneath.
- Give a practical example from code or a project.
- Close with a trade-off, pitfall or when you'd use it.
Common mistakes
- Wrapping everything in useMemo/useCallback “for performance”.
- Thinking useMemo prevents a component from re-rendering.
Likely follow-up questions
- Why does useCallback do nothing if the child isn't wrapped in React.memo?
- How does the React Compiler change this advice?
Example strong answer
useMemocaches a computed value;useCallbackcaches a function so its identity stays the same between renders —useCallback(fn, deps)is equivalent touseMemo(() => fn, deps). Both recompute only when a dependency changes. They're worth it in three cases: an expensive calculation like filtering thousands of rows, passing an object or callback to a child wrapped inReact.memoso it can skip renders, and keeping a value stable when it's an effect dependency. Otherwise they add complexity for nothing — I measure with the Profiler first. With the React Compiler, much of this memoisation is automatic.- useMemo caches a value.
4.
What are controlled and uncontrolled components?
BeginnerTechnicalPractise this question and get feedbackWhat the interviewer is evaluating
Form handling fundamentals.
Key points a strong answer covers
- Controlled = React state. A controlled input's value comes from React state and changes through onChange.
- Uncontrolled = DOM keeps value. An uncontrolled input keeps its own value in the DOM; you read it with a ref or FormData.
- Trade-offs. Controlled suits instant validation and formatting; uncontrolled is simpler and cheaper for big forms.
- Libraries / file inputs. Libraries like React Hook Form are largely uncontrolled; file inputs are always uncontrolled.
Suggested answer structure
- Define it in one sentence.
- Explain how it works underneath.
- Give a practical example from code or a project.
- Close with a trade-off, pitfall or when you'd use it.
Common mistakes
- Switching an input from uncontrolled to controlled (value undefined → string).
- Not knowing file inputs can't be controlled.
Likely follow-up questions
- What causes the “changing an uncontrolled input to be controlled” warning?
- How would you handle a 50-field form efficiently?
Example strong answer
A controlled input gets its value from React state and updates through
onChange, so React is the single source of truth — ideal when you need instant validation, formatting like a phone mask, or to enable a button as the user types. An uncontrolled input keeps its own value in the DOM; you set adefaultValueand read it on submit with a ref orFormData. That's simpler and avoids a re-render per keystroke, which helps on big forms — React Hook Form is built on this. File inputs are always uncontrolled. A common bug is starting withvalue={undefined}and later passing a string, which flips an input from uncontrolled to controlled.5.
How does useEffect work, and what are the most common mistakes with it?
IntermediateTechnicalPractise this question and get feedbackWhat the interviewer is evaluating
Correct mental model of effects as synchronisation, not lifecycle methods.
Key points a strong answer covers
- Runs after commit. Effects run after React commits the render to the screen.
- Dependencies. They re-run when dependencies change; missing deps cause stale values.
- Cleanup. The returned cleanup runs before the next effect and on unmount.
- Don't need an effect. Derived state and event-driven logic don't belong in effects; data fetching is better in a library or framework.
- Strict mode double run. In development Strict Mode, effects mount, clean up and mount again to surface missing cleanup.
Suggested answer structure
- Define it in one sentence.
- Explain how it works underneath.
- Give a practical example from code or a project.
- Close with a trade-off, pitfall or when you'd use it.
Common mistakes
- Using an effect to copy props into state.
- Fetching without cancelling, causing race conditions.
Likely follow-up questions
- Why does my effect run twice in development?
- How do you avoid a race condition when fetching in an effect?
Example strong answer
useEffectsynchronises a component with something outside React — a subscription, a timer, the document title. It runs after the render is committed, and again whenever a dependency changes; the function you return is the cleanup, which runs before the next run and on unmount. The common mistakes are missing dependencies, which give stale values; no cleanup, which leaks listeners; fetching without ignoring stale responses, which causes race conditions; and using effects for things that aren't effects — derived values should be calculated during render, and logic caused by a click belongs in the event handler. In development Strict Mode effects run, clean up and run again to expose missing cleanups.6.
How do you manage complex application state in React?
AdvancedTechnicalPractise this question and get feedbackWhat the interviewer is evaluating
Architecture judgement: choosing the simplest tool that fits.
Key points a strong answer covers
- Local first. Keep state as close as possible to where it's used; lift only when needed.
- Server state is different. Remote data belongs in a cache library (TanStack Query, SWR) or the framework, not global state.
- Context for low-frequency. Context suits rarely changing values; frequent updates re-render every consumer.
- Global stores. For complex shared client state: useReducer, Zustand or Redux Toolkit.
- URL state. Filters and selections often belong in the URL.
Suggested answer structure
- Define it in one sentence.
- Explain how it works underneath.
- Give a practical example from code or a project.
- Close with a trade-off, pitfall or when you'd use it.
Common mistakes
- Putting everything, including API data, in one global store.
- Using Context for fast-changing values like an input.
Likely follow-up questions
- What's the difference between client state and server state?
- When would you pick Redux Toolkit over Zustand?
Example strong answer
I start by sorting state into kinds. Server state — data from APIs — goes in a caching layer such as TanStack Query or the framework's data loading, which handles loading, caching and refetching. URL state, like filters and the current tab, goes in search params so it's shareable. UI state stays local with
useState, lifted only as far as needed, anduseReducerwhen updates have complex rules. Context is for low-frequency values like the theme or current user, since every consumer re-renders on change. Only if there's genuinely complex shared client state — a multi-step editor, say — do I add a store like Zustand or Redux Toolkit.7.
How would you optimise a slow React application?
AdvancedTechnicalPractise this question and get feedbackWhat the interviewer is evaluating
A measured, methodical approach to performance.
Key points a strong answer covers
- Measure first. Profile with the React DevTools Profiler and Performance panel; check Core Web Vitals.
- Reduce re-renders. Avoid unnecessary renders: colocate state, split context, memoise where measured.
- Large lists. Virtualise long lists.
- Bundle / loading. Code-split routes and heavy components; optimise images and bundle size.
- Defer non-urgent work. useTransition / useDeferredValue keep typing responsive; move heavy work to a worker.
Suggested answer structure
- Define it in one sentence.
- Explain how it works underneath.
- Give a practical example from code or a project.
- Close with a trade-off, pitfall or when you'd use it.
Common mistakes
- Jumping straight to memoising everything without profiling.
- Ignoring network and bundle size and only looking at renders.
Likely follow-up questions
- What does the Profiler's flame graph tell you?
- When would you use
useDeferredValue?
Example strong answer
First I measure, because slow can mean many things. I check Core Web Vitals to see whether it's load time (LCP) or interaction (INP), then profile the slow interaction with the React DevTools Profiler and the browser's Performance panel. For load time: code-split routes and heavy widgets with
lazy, trim the bundle, optimise images. For slow interactions: find components re-rendering unnecessarily — often state too high up or a context with a frequently changing value — and colocate state, split context, or memoise the expensive child. Long lists get virtualised. For heavy filtering while typing,useDeferredValueoruseTransitionkeeps input responsive. Then I measure again to confirm the gain.8.
What are React Server Components, and how are they different from server-side rendering?
AdvancedTechnicalPractise this question and get feedbackWhat the interviewer is evaluating
Up-to-date knowledge of modern React architecture.
Key points a strong answer covers
- Render only on the server. Server Components run only on the server; their code never ships to the browser.
- Zero client JS. They add no JavaScript to the bundle.
- Direct data access. They can be async and read databases or secrets directly.
- Client components for interactivity. Interactivity needs Client Components marked with 'use client'.
- Not the same as SSR. SSR renders HTML for the first load then hydrates everything; RSC is about which components ever reach the client.
Suggested answer structure
- Define it in one sentence.
- Explain how it works underneath.
- Give a practical example from code or a project.
- Close with a trade-off, pitfall or when you'd use it.
Common mistakes
- Saying RSC is just another name for SSR.
- Passing functions or class instances as props from server to client.
Likely follow-up questions
- What can you pass as props from a Server Component to a Client Component?
- Can a Client Component import a Server Component?
Example strong answer
Server Components are components that run only on the server — at build time or per request — and send their rendered result to the client, never their code. So they add no JavaScript to the bundle, can be async, and can read a database or use secrets directly. Anything interactive — state, effects, event handlers — goes in a Client Component marked
'use client', which you can render inside a Server Component, passing serialisable props. That's different from SSR: SSR renders all components to HTML for a fast first paint and then hydrates them all in the browser, so their code still ships. RSC changes which components ever reach the client. In practice you use both together.9.
When do you write a custom hook? Give an example.
IntermediateTechnicalPractise this question and get feedbackWhat the interviewer is evaluating
Code organisation and reuse of stateful logic.
Key points a strong answer covers
- Reuse stateful logic. Custom hooks extract and reuse stateful logic between components.
- Naming / rules of hooks. They start with
useand follow the rules of hooks. - Separate state per caller. Each component calling the hook gets its own state; hooks share logic, not state.
- Example. e.g. useDebounce, useLocalStorage, useMediaQuery, useOnlineStatus.
Suggested answer structure
- Define it in one sentence.
- Explain how it works underneath.
- Give a practical example from code or a project.
- Close with a trade-off, pitfall or when you'd use it.
Common mistakes
- Thinking two components using the same hook share state.
- Wrapping trivial one-liners in hooks.
Likely follow-up questions
- How would you test a custom hook?
- Why must hooks be called in the same order every render?
Example strong answer
I write a custom hook when two or more components need the same stateful logic, or when a component's logic is getting long and has a clear name. For example
useDebouncedValue(value, delay)wraps a state and a timer effect, anduseMediaQuery('(max-width: 640px)')subscribes to a media query and cleans up. A custom hook is just a function starting withusethat calls other hooks, so it follows the rules of hooks — top level, same order every render. Importantly, it shares logic, not state: every component that calls it gets its own independent state. If I need shared state, that's context or a store.10.
What is React Context for, and what are its performance pitfalls?
IntermediateTechnicalPractise this question and get feedbackWhat the interviewer is evaluating
Knowing when Context is the right tool.
Key points a strong answer covers
- Avoid prop drilling. Context passes data through the tree without prop drilling.
- Good uses. Theme, current user, locale, feature flags — values that change rarely.
- Re-renders all consumers. When the value changes, every consumer re-renders.
- Mitigations. Split contexts, memoise the value object, or use a store with selectors for fast-changing state.
Suggested answer structure
- Define it in one sentence.
- Explain how it works underneath.
- Give a practical example from code or a project.
- Close with a trade-off, pitfall or when you'd use it.
Common mistakes
- Creating the value object inline so it changes every render.
- Using one giant context for the whole app.
Likely follow-up questions
- Why should the provider's value be memoised?
- How does a store with selectors avoid unnecessary renders?
Example strong answer
Context lets a value reach any depth of the tree without passing props through every level — good for the theme, the signed-in user, the locale or feature flags. The catch is that when the provider's value changes, every component that reads that context re-renders. So I keep fast-changing state out of it, split unrelated values into separate contexts, and memoise the value object —
value={{ user, logout }}inline creates a new object each render and re-renders all consumers. For frequently updated shared state, a store like Zustand with selectors is better because components re-render only when the slice they select changes.11.
How do you handle errors in a React app?
IntermediateTechnicalPractise this question and get feedbackWhat the interviewer is evaluating
Resilience and user experience when things fail.
Key points a strong answer covers
- Error boundaries. Error boundaries catch render errors in their subtree and show a fallback UI.
- What they don't catch. They don't catch errors in event handlers or async code — handle those with try/catch.
- Placement. Place boundaries around routes and risky widgets, not just the root.
- Reporting & recovery. Report errors to monitoring and offer a retry or reset.
Suggested answer structure
- Define it in one sentence.
- Explain how it works underneath.
- Give a practical example from code or a project.
- Close with a trade-off, pitfall or when you'd use it.
Common mistakes
- Expecting an error boundary to catch a failed fetch in an event handler.
- One boundary at the root that blanks the whole app.
Likely follow-up questions
- Why are error boundaries class components?
- How would you reset an error boundary after the user retries?
Example strong answer
For rendering errors I use error boundaries: a component — still a class, or a library like react-error-boundary — that catches errors thrown while rendering its children and shows a fallback instead of a blank page. I place them around routes and risky widgets, so a broken chart doesn't take the whole dashboard down, and the fallback offers a retry that resets the boundary. They don't catch errors in event handlers, timers or promises, so those get try/catch and a visible error state. Every caught error is reported to monitoring like Sentry, with enough context to reproduce it.
12.
What do Suspense and transitions (useTransition) do?
AdvancedTechnicalPractise this question and get feedbackWhat the interviewer is evaluating
Familiarity with concurrent React features.
Key points a strong answer covers
- Suspense shows a fallback. Suspense shows a fallback while children wait for code or data.
- Works with lazy and data. It works with
lazy()code splitting and Suspense-aware data sources, and enables streaming. - Transitions are non-urgent.
startTransitionmarks an update as non-urgent so urgent input stays responsive. - Avoid jarring loaders. Transitions keep showing the old UI (with
isPending) instead of a fallback flashing.
Suggested answer structure
- Define it in one sentence.
- Explain how it works underneath.
- Give a practical example from code or a project.
- Close with a trade-off, pitfall or when you'd use it.
Common mistakes
- Thinking Suspense fetches data by itself.
- Wrapping every update in a transition.
Likely follow-up questions
- How does
useDeferredValuediffer fromuseTransition? - How does Suspense enable streaming SSR?
Example strong answer
Suspense lets a component wait for something — code loaded with
lazy(), or data from a Suspense-aware source like a framework loader or theusehook — and shows the nearest boundary's fallback meanwhile. Boundaries let you decide where loading states appear, and on the server they enable streaming HTML in chunks. Transitions are about priority: wrapping an update instartTransitionmarks it as non-urgent, so typing stays responsive while React prepares the new screen in the background, and an already-visible UI isn't replaced by a fallback — you getisPendingto show a subtle indicator. A typical use is switching tabs or filtering a big list.13.
How do you test React components?
IntermediateTechnicalPractise this question and get feedbackWhat the interviewer is evaluating
Testing philosophy and practical tooling.
Key points a strong answer covers
- Test behaviour not implementation. Test what the user sees and does, not internal state.
- Testing Library. React Testing Library queries by role and text.
- User events / async. Simulate real interactions with user-event and await async UI.
- Mock the network. Mock APIs at the network level (MSW) rather than mocking internals.
- Test pyramid. Mostly integration-style component tests, plus a few end-to-end tests with Playwright.
Suggested answer structure
- Define it in one sentence.
- Explain how it works underneath.
- Give a practical example from code or a project.
- Close with a trade-off, pitfall or when you'd use it.
Common mistakes
- Testing internal state or snapshot-testing everything.
- Querying by class names or test ids when a role would do.
Likely follow-up questions
- Why prefer
getByRoleovergetByTestId? - What would you cover with Playwright rather than unit tests?
Example strong answer
I test behaviour the way a user experiences it. With React Testing Library I render the component, find elements by role and accessible name —
getByRole('button', { name: /save/i })— interact with user-event, and assert on what appears. For async UI I usefindByqueries. I mock the network with MSW instead of mocking hooks or modules, so components run their real code. I avoid testing internal state and large snapshots, which break on harmless refactors. Most coverage comes from these integration-style tests, with a handful of Playwright end-to-end tests for critical flows like sign-up and checkout.
Ready to answer them out loud?
Run a timed next.js developer mock interview, type or speak your answers, and get a score breakdown with what to improve.