Lesson 22 of 80
A newer split in React's model: some components run only on the server and send HTML, never shipping their code to the browser at all — a fundamentally different tradeoff than 'just render it server-side.'
14 min read
Every option explains itself — why the right one is right, and why each wrong one is wrong. Miss one and it comes back later on a spaced-repetition schedule.
Question 1 of 2
Does a Server Component's code get included in the JavaScript bundle sent to the browser?
Hints without spoilers, and a plain explanation of why a wrong answer was wrong — answered only from this lesson. Free account, no card.
Sign up freeWhat interviewers actually ask about this, and what a strong answer has to cover.
A strong answer covers
Likely follow-ups
Every component you've met so far in this track eventually runs in the browser — even a server-rendered one is hydrated with its JS shipped down and re-executed client-side. React Server Components (RSC) are different: they render only on the server, output is sent as a description of UI (not HTML strings, not JS), and their code never ships to the browser at all.
// Server Component (default in a framework like Next.js's app router) — no directive needed
async function ProductList() {
const products = await db.query("SELECT * FROM products"); // runs on the server, directly
return <ul>{products.map((p) => <li key={p.id}>{p.name}</li>)}</ul>;
}
// Client Component — opts in explicitly
"use client";
function AddToCartButton({ productId }) {
const [loading, setLoading] = useState(false); // needs interactivity -> must be client
return <button onClick={() => addToCart(productId)}>Add to cart</button>;
}
ProductList can await a database call directly in the component — no API route, no useEffect, no loading state to manage, because it never runs on a device where "loading" is observable; the server just doesn't respond until it's ready. AddToCartButton needs useState and an onClick, which requires actually running in the browser, so it opts in with "use client".
Server Component: runs only on the server, ships zero JS to the browser, can await a database call directly.
children/props, it can't import and render one itself, since a Server Component might do things (query a database) that make no sense to run in the browser.useState, useEffect, onClick; anything needing interactivity has to live in (or below) a "use client" boundary.This is one of the more current React topics to come up at senior interviews specifically because it changes real architecture decisions — knowing where to draw the client/server boundary in a component tree, not just that the feature exists, is the actual signal.