Hydration is the step where React, running in the browser, attaches to HTML that was already rendered on the server. Instead of throwing that HTML away and rebuilding the DOM, React renders the same component tree in memory, walks the existing DOM, adopts its nodes, and attaches event handlers and state, which makes the static page interactive. It's done with hydrateRoot(container, <App />) (React 18+). It only works if the client's first render produces the same markup as the server's. Otherwise you get hydration mismatch errors.
Server-side rendering gives users meaningful HTML fast (better FCP/LCP, SEO, works before JS loads). But that HTML is inert: buttons don't respond until JavaScript runs. Hydration connects the two without re-creating the DOM, so:
// client entry
import { hydrateRoot } from 'react-dom/client';
import App from './App';
hydrateRoot(document.getElementById('root'), <App />);
Frameworks such as Next.js and React Router do this for you.
Before (React 17 and earlier): hydration was all-or-nothing. The whole app's JS had to load, and the whole tree hydrated in one blocking pass before anything was interactive.
React 18:
<Suspense> boundary hydrates independently. Code-split parts can hydrate later.React 19: clearer mismatch error messages with a diff, tolerance for extra nodes injected by browser extensions or third-party scripts in <head>/<body>, and the onRecoverableError root option for reporting recovered mismatches.
The client still downloads, parses and executes all component code for the hydrated tree, and re-renders it. That's the "uncanny valley" where a page looks ready but doesn't respond (bad for INP/TBT). Mitigations:
lazy + Suspense).'use client' islands hydrate.Date.now(), Math.random(), typeof window branches, locale/time-zone formatting, or reading localStorage during render produce different output on client and server. Move client-only values into useEffect, or use useSyncExternalStore with a getServerSnapshot.<p><div/></p>, <a> inside <a>) is repaired by the browser's parser, so the DOM no longer matches what React expects.createRoot instead of hydrateRoot on SSR markup discards it and renders from scratch.Spotted a mistake or a rights concern? Report an issue