Server and Client Components in Next.js · senior
The "use client" boundary
"use client" declares a boundary in the module graph: the file and everything it imports become client code, so put it on small interactive leaves and pass server-rendered content into them as children.
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceThe notes
What you must know
- Use Client Components for state, event handlers, effects, browser APIs and custom hooks. Use Server Components to fetch data near the source, use secrets, and send less JavaScript.
- Everything a
"use client"file imports and renders directly is in the client bundle. Server Components passed aschildrenor props are NOT imported into it; they are rendered on the server and passed as output. - First load: HTML for a fast preview, the RSC payload to reconcile the trees, then JavaScript to hydrate Client Components. Later navigations: the RSC payload is fetched (and prefetched); Client Components render on the client.
- Push the boundary down:
<AddToCartButton>is a client component; the product page stays a server component. - Context providers: wrap them in a small client component that takes
childrenand render it as deep as possible (around{children}, not the whole<html>). - Third-party components that use hooks but lack
"use client": re-export them from your own"use client"file. - Library authors add
"use client"to client entry points (some bundlers strip it). - Verify with the bundle analyzer: Turbopack Bundle Analyzer (16.1+, route summary and diffing in 16.4).
The red pen
Common traps: mistake → fix
Mistake: "Server Components can't be interactive, so the whole page must be a client component"
Fix: only the interactive leaf needs it.
Mistake: "A Client Component can import a Server Component"
Fix: it can only receive one as a prop/children.
Mistake: "Client Components are not server-rendered"
Fix: they are prerendered to HTML on first load, then hydrated.
Easy to hard
Questions interviewers ask, easy to hard
- A teammate put
"use client"on a 600-line page because one button needsonClick. What is the problem and the fix? - Can a Client Component render a Server Component?
- What makes something need to be a Client Component?
- Where do context providers go in the App Router?
- How do you verify the bundle impact?
Practise
Practise with these questions
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceYour first interview is free
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.