No useState, useEffect, or Event Handlers
You'll learn: Why Server Components can't use client-side React hooks or handle browser events.
The Core Constraint
Server Components execute only on the server, rendering to a serialized format before any JavaScript reaches the browser. Because they never run in the client environment, they can't use hooks that depend on browser APIs or manage client-side state.
Think of Server Components like a chef preparing ingredients in the kitchen (server) before sending the finished dish to the dining room (browser). The chef can't taste the food from the diner's perspective or respond to the diner saying "more salt, please" — that interaction happens in a different place entirely.
What You Can't Use
// ❌ All of these break in Server Components
function ServerComponent() {
const [count, setCount] = useState(0); // No client state
useEffect(() => {
console.log('mounted'); // No lifecycle effects
}, []);
return <button onClick={() => setCount(count + 1)}>
Click me {/* No event handlers */}
</button>;
}
These features require:
- Browser APIs (DOM, timers, events)
- Re-rendering after mount
- Interactivity that Server Components don't provide
The Analogy
Server Components are like a printed newspaper — they're created once with all the content, then delivered. You can't click a button in a newspaper to update the text. For interactivity, you need Client Components (like a tablet with an app).
Key Takeaway: Server Components execute once on the server and cannot use useState, useEffect, or event handlers because these features require the browser runtime and client-side reactivity.