Free auditStart free
GlossaryGlossary · Rendering

Hydration

Hydration attaches JavaScript to server-rendered HTML so the page becomes interactive. What can go wrong, how mismatches happen, and how to check server HTML.

3 min
read
3
sources
Oct 30, 2026
updated
Scaplet Editorial Team
author
In one line

Hydration is the step where a JavaScript framework attaches to HTML that was already rendered on the server, then takes over managing that DOM so the page responds to clicks. In React, hydrateRoot does this. For SEO, the point is that the server HTML should already contain your content, and the hydrated page should match it.

30-second check

Is this costing your site traffic?

Four quick questions, then a straight answer.

1/4Have you checked your own site for this?
Summarize this page withChatGPTClaudePerplexityGoogleAI Mode

At a glance

4 facts from the sources below
`hydrateRoot(domNode, reactNode)`
React API
HTML already rendered on the server
Needs
Treat as a bug; repairs are not guaranteed
Mismatch
Use `createRoot` instead
No server HTML
03At a glance

Mismatches and how they happen

Cause listed in React's docs

typeof window !== 'undefined' checks in rendering

Fix direction
Render the same tree on both sides, then update in an Effect
Cause listed in React's docs

Browser-only APIs such as window.matchMedia during render

Fix direction
Read them in an Effect after hydration
Cause listed in React's docs

Different data on the server and the client

Fix direction
Make both sides render the same values
Cause listed in React's docs

Extra whitespace around the root's generated HTML

Fix direction
Remove stray newlines between the container and the markup
A hydration mismatch, and the fix
// Mismatch: server renders one value, browser another
function Greeting() {
  const w = typeof window !== 'undefined' ? window.innerWidth : 0;
  return <p>{w > 600 ? 'Wide' : 'Narrow'}</p>;
}

// Safer: render the same thing first, then update after hydration
function Greeting() {
  const [wide, setWide] = useState(false);
  useEffect(() => setWide(window.innerWidth > 600), []);
  return <p>{wide ? 'Wide' : 'Narrow'}</p>;
}

React says hydrateRoot expects content identical to the server render and tells you to treat mismatches as bugs. It can recover from some errors, but the worst case is event handlers attached to the wrong elements, and it gives no guarantee that attribute differences are patched. For an unavoidable difference such as a timestamp, suppressHydrationWarning works one level deep and is an escape hatch. React does not repair mismatched text content.

04How it works

Check it in 2 minutes

1. What the server sent (no JavaScript executed)
curl -s https://example.com/page | grep -c '<h1'
curl -s https://example.com/page | grep -o '<title>[^<]*</title>'
2. In the browser console after the page loads
document.querySelector('h1')?.textContent
document.title
  1. 01

    Fetch the raw HTML

    Run the curl lines. Your headline, main copy, links and title should appear in this output.

  2. 02

    Read the hydrated DOM

    Open DevTools, then compare the console output with what curl printed. They should agree.

  3. 03

    Watch the console

    In development, React warns about mismatches during hydration. Fix every warning.

  4. 04

    See what Google sees

    Run the URL Inspection tool and open the rendered HTML. Google says content missing there cannot be indexed.

Sources · 3

Every fact, linked and dated.

Official docs first. The date is when we last opened each page.
  • react.dev
  • google.com
  1. 01hydrateRoot (React reference)react.dev · checked 2026-11-01
  2. 02JavaScript SEO basicsdevelopers.google.com · checked 2026-11-01
  3. 03Fix Search-related JavaScript problemsdevelopers.google.com · checked 2026-11-01
Questions

Asked a lot.

2 questions people ask next, answered from the sources on this page.

01Is hydration the same as server-side rendering?

No. Server-side rendering produces the HTML on the server. Hydration is the later browser step that attaches JavaScript to that HTML. A server-rendered React page typically uses both.

02Does hydration hurt SEO?

Not by itself. The risk is a mismatch between server and client output, or content that only exists after hydration. Verify with the raw HTML and the rendered HTML in Google's tools.

Free · 2 minutes

Know the term. Now check your site.

The free audit reads robots.txt, sitemaps, status codes, canonicals, redirects and structured data.

Free, no card60 secondsNobody will call you
  • 46 fixes shipped without a ticket Brightpipe
  • +212% organic clicks in 90 days Ledgerly