What is hydration, and why can it hurt performance?
Many modern frameworks render HTML on the server and then make it interactive in the browser. That second step is called hydration.
How it works:
- The server renders the page to HTML, so users see content quickly.
- The browser downloads the JavaScript for the components on that page.
- The framework runs the components again in the browser, matches them to the existing HTML, and attaches event listeners and state.
Why it can be costly:
- The page looks ready but isn't interactive until hydration completes; clicks may do nothing.
- The browser must download, parse and execute JavaScript for the whole page, even for static parts.
- On slower phones, this can cause poor responsiveness metrics.
- Hydration mismatches happen when server and client render different output (dates, random values, browser-only data), causing warnings or re-rendering.
Approaches to reduce the cost:
- Partial hydration / islands: only interactive parts ship JavaScript; the rest stays static HTML.
- Progressive or lazy hydration: hydrate components when they become visible or are interacted with.
- Server components: components that run only on the server and send no JavaScript for themselves.
- Resumability: some frameworks serialise state so the client can resume without re-running components.
Practical tips: keep client-side components small, move static content out of interactive trees, and measure with real devices.
Has hydration been a noticeable cost in your apps? Which approach to reducing it has worked best for you?
Comments · 3
Newcomer question: why can't the browser just reuse the server's HTML as-is, without redoing the work?
The server sends plain HTML, but the browser still has to attach event handlers and rebuild the framework's state. Hydration is that attaching step.
Worth knowing for conversion. A page that looks loaded but can't be clicked yet frustrates users and hurts the numbers.