// A Server Component - runs only on the server
async function ProjectList() {
const projects = await db.query('SELECT * FROM projects');
return (
<ul>{projects.map(p => <li key={p.id}>{p.title}</li>)}</ul>
);
}
Why this is different from getServerSideProps
A traditional server-rendered page still ships the component's JavaScript to the browser for hydration. A Server Component's code never does - it renders once, on the server, and only the resulting HTML (plus a compact description React uses to merge it in) reaches the client. Smaller client bundles, direct database access from within the component, no separate API layer required for that specific piece of UI.
Client Components still exist, explicitly marked
'use client';
function LikeButton() {
const [liked, setLiked] = useState(false);
return <button onClick={() => setLiked(!liked)}>♥</button>;
}
Anything genuinely interactive - click handlers, local state - still needs to be a Client Component, opted into explicitly. Most of a typical page, it turns out, doesn't.
A component that never ships to the browser
A traditional React component's code is bundled and sent to the client regardless of whether it needs interactivity. A Server Component renders entirely on the server and sends only its resulting HTML - the component's own JavaScript never reaches the browser at all, which can meaningfully shrink bundle size for content-heavy pages.
// This runs only on the server - no 'use client' directive needed
async function ProductList() {
const products = await db.query('SELECT * FROM products');
return <ul>{products.map(p => <li key={p.id}>{p.name}</li>)}</ul>;
}
The boundary is the whole design challenge
Server and Client Components can nest, but a Server Component can't be imported directly into a Client Component - data has to flow down as props instead. Deciding where that boundary sits (usually: server for data fetching and static structure, client for anything with onClick, state, or browser APIs) is the actual skill to learn; the syntax itself is a small part of the real work.