Skip to content

/glossary/react/hydration

What is hydration in React and Next.js?

The commands on this page have not been executed by our verification runner yet.updated 2026-10-20
tool
React
versions
React 18, React 19
os
any

Hydration is the step in which React, running in the browser, takes HTML that was already rendered on the server and attaches its components, state and event handlers to the existing DOM instead of building the DOM again. The page is visible as soon as the HTML arrives and becomes interactive once hydration finishes.

How it works

  1. The server renders the component tree to HTML (renderToPipeableStream, or a framework such as Next.js).
  2. The browser shows that HTML immediately.
  3. The JavaScript bundle loads and calls hydrateRoot(container, <App />).
  4. React renders the same tree in memory, walks the existing DOM, checks that it matches, and wires up event listeners.

If the first client render produces different output, React reports a hydration error and re-renders that part on the client.

TermMeaning
SSRserver-side rendering: HTML is produced per request
SSGstatic generation: HTML is produced at build time
Hydration mismatchserver HTML differs from the first client render
Selective hydrationReact 18+ hydrates parts of the page as their code arrives, inside Suspense boundaries
React Server Componentscomponents that run only on the server and ship no JavaScript, so they need no hydration

Rule for hydration-safe components: the first render must not depend on anything that only the browser knows (window size, local time, localStorage). Read those values in useEffect, after hydration.

Sources