Key difference between Server and Client Components in Next.js?
Tests App Router rendering boundaries. A strong answer contrasts server-only execution against browser interactivity, choosing Client Components only for state, effects, or events.
What's really being asked
This question checks if you understand the App Router's dual-environment model and can articulate why Next.js defaults to server rendering. Interviewers want to see that you know where code executes, what ships to the browser, and how that impacts bundle size, data access, and security. It also reveals whether you treat Next.js as a plain React SPA or as a framework with distinct server and client boundaries.
The full answer
First, execution environment: Server Components run only on the server and their code never downloads to the browser, which eliminates client bundle size for those components. Second, capability differences: Server Components can import server-only modules like database drivers or filesystem utilities, while Client Components can use React hooks like useState and useEffect, event handlers like onClick, and browser APIs like localStorage. Third, the opt-in rule: in the App Router, every component is a Server Component by default, and you must add the "use client" directive at the top of a file to create a Client Component. Fourth, the decision criteria: you choose a Client Component precisely when you need interactivity, client-side state, effects, or browser-only APIs; everything else should stay on the server.
The mistakes people make
A major red flag is saying that Client Components do not run on the server; in reality, they render on the server during SSR and then hydrate in the browser. Another mistake is claiming that Server Components cannot render HTML; they absolutely do, they just do it without client-side JavaScript. Candidates also err by stating that "use client" is required for all components or that hooks work in Server Components. Finally, suggesting that you should wrap entire pages in "use client" just because one small element needs interactivity shows a lack of understanding of granular component boundaries.
What usually comes next
The interviewer may ask how you pass data from a Server Component to a Client Component, which is done via props, but you cannot import a Server Component directly into a Client Component unless it is passed as a child or prop. They might ask about the impact on bundle size if you mark too many components as client components. Another follow-up is whether you can use context in Server Components, which you cannot, so shared state must be handled carefully across the boundary. You might also be asked how third-party packages that use hooks should be imported, which requires marking the consuming component as a client component.
A concrete example
Imagine an e-commerce product page. The page layout, product description, and reviews list should be Server Components so they can fetch data directly from a database and send no JavaScript to the browser. The "Add to Cart" button, however, needs onClick handlers and useState to manage loading and confirmation feedback, so it should be a Client Component imported into that otherwise server-rendered page. This keeps the client bundle small while isolating interactivity to exactly the pieces that need it.
Interview question
You are building a Next.js App Router page that fetches product data from a database and includes an interactive 'Add to Cart' button. What is the recommended approach?
- a.Keep the page as a Server Component and import only the button as a Client ComponentCorrect
- b.Keep both the page and button as Server Components since they can render interactive HTML
- c.Mark the entire page as a Client Component so the button can use onClick
- d.Fetch the data inside a Client Component using useEffect and add the button there
Why? this is the answer
The App Router defaults to Server Components for direct data access and minimal bundle size, while Client Components should be used granularly only where interactivity is needed. Option C is a common mistake that ships unnecessary JavaScript to the browser, and D incorrectly assumes Server Components can handle client-side interactions.
Just read this? Test yourself on what you have been reading.
Read the original → nextjs.org
Put your scrolling time to good use
Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.
The iPhone app is on the way
We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.
Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.
We are hiring for this. Open roles that interview on next.js — each one lists the topics its interview covers.
See open roles