Course contentsShow
← React
Lesson 1524 of 2,39638. Server Components FundamentalsFree lesson

Server Components Run Once, Not Twice

Unlike SSR which runs on server then hydrates on client, Server Components execute only on the server with no client-side re-execution.

Server Components Run Once, Not Twice

What you'll learn: How Server Components fundamentally differ from traditional SSR by executing only on the server with no client-side repeat execution.


The Old SSR Mental Model

In traditional Server-Side Rendering (SSR), your React components run twice:

  1. On the server to generate initial HTML
  2. On the client during hydration to attach event handlers and make the page interactive

This means the same component code executes in two environments, which is why you need checks like typeof window !== 'undefined' and why you can't use server-only APIs directly in components.

Server Components: True Single-Execution

Server Components break this pattern completely. They:

  • Run once on the server
  • Never run on the client
  • Never hydrate
  • Send their rendered output (serialized React tree) to the client, not their source code

Think of it like this: traditional SSR is like sending a cake recipe that the kitchen makes, then the customer re-makes at their table. Server Components are like sending a finished slice of cake — the customer never sees or repeats the baking process.

What This Means Practically

Because Server Components execute only once on the server:

  • You can access databases directly without APIs
  • You can use server-only packages without bundle bloat
  • There's no hydration mismatch risk for these components
  • The client never receives or re-executes their code

The "Zero-JS Promise" from the previous lesson is possible precisely because these components don't need client-side JavaScript to re-run — they're already fully rendered.


Key Takeaway: Server Components execute once on the server and send rendered output, eliminating the traditional SSR pattern of server execution followed by client-side hydration/re-execution.