Performance: When to use client components
HIGH IMPACT
This affects page load speed and interaction responsiveness by deciding which parts of the page run in the browser versus on the server.
"use client"; import React from 'react'; export default function Button() { const [count, setCount] = React.useState(0); return <button onClick={() => setCount(count + 1)}>Clicked {count} times</button>; }
export default function Button() { const [count, setCount] = React.useState(0); return <button onClick={() => setCount(count + 1)}>Clicked {count} times</button>; } // No 'use client' directive, so this runs as a server component
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Using client components only for interactive parts | Minimal, scoped to interactive elements | Single reflow on interaction | Low paint cost | [OK] Good |
| Marking entire page as client component unnecessarily | Large DOM with many nodes | Multiple reflows during hydration | High paint cost | [X] Bad |