# 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.

Canonical: https://scaplet.com/glossary/hydration

Glossary Glossary · Rendering

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 with [ChatGPT](https://chatgpt.com/?hints=search&q=Summarize%20https%3A%2F%2Fscaplet.com%2Fglossary%2Fhydration%20(%22Hydration%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [Claude](https://claude.ai/new?q=Summarize%20https%3A%2F%2Fscaplet.com%2Fglossary%2Fhydration%20(%22Hydration%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [Perplexity](https://www.perplexity.ai/search?q=Summarize%20https%3A%2F%2Fscaplet.com%2Fglossary%2Fhydration%20(%22Hydration%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [![Google](/logos/ai/google-color.svg)AI Mode](https://www.google.com/search?udm=50&q=Summarize%20https%3A%2F%2Fscaplet.com%2Fglossary%2Fhydration%20(%22Hydration%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.)

## 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

_01_At a glance

## What hydration actually does

With [server-side rendering](/glossary/server-side-rendering), the browser receives finished HTML and shows it before any JavaScript runs. That HTML is inert: buttons exist but nothing happens on click. Hydration runs the same components in the browser and attaches React to the existing nodes.

Step

### 1. Server renders components to HTML

Where

Server

State of the page

Complete content, no behavior

Step

### 2. Browser paints the HTML

Where

Browser

State of the page

Readable and visible, not interactive

Step

### 3. JavaScript loads and `hydrateRoot` runs

Where

Browser

State of the page

React attaches to the existing HTML

Step

### 4. React manages the DOM

Where

Browser

State of the page

Interactive

React's reference says `hydrateRoot` attaches to the HTML inside the DOM node you give it and takes over managing the DOM there. If there is no pre-rendered HTML, it says to use `createRoot()` instead, which renders from scratch in the browser. That second path is [client-side rendering](/glossary/client-side-rendering).

_02_Trade-offs

## Why it matters for search

Google processes JavaScript pages in crawling, [rendering](/glossary/rendering) and indexing phases, and a headless Chromium renders the page when resources allow. Its JavaScript docs also recommend server-side or [pre-rendering](/glossary/static-site-generation), partly because not all bots run JavaScript. Hydration is what makes that server HTML interactive afterward, so it is the second half of a server-rendered setup.

Strengths
- Content, links and metadata are in the first HTML response, so a crawler does not depend on running your scripts
- Users see content before JavaScript finishes loading
- React attaches to the existing HTML rather than starting from an empty container

Weaknesses
- Server and client must produce the same output, which adds a class of bugs
- The framework code still has to download and run before the page responds
- Browser-only code in render logic needs care

**Google's docs do not mention hydration by name**Google's [JavaScript SEO](/glossary/javascript-seo) basics page describes rendering and recommends server-side or pre-rendering, but does not use the word hydration. What it says is that content must be visible in the [rendered HTML](/glossary/rendered-html) to be indexed.

_03_At 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.

_04_How 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
```

**Empty shell is not hydration**If `curl` shows only an empty `<div id="root">`, the page is client-side rendered and there is nothing to hydrate. Google's JavaScript docs describe this app shell pattern as one where Google has to run JavaScript to see the content.

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](/glossary/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. 01 [hydrateRoot (React reference)](https://react.dev/reference/react-dom/client/hydrateRoot) react.dev · checked 2026-11-01
2. 02 [JavaScript SEO basics](https://developers.google.com/search/docs/crawling-indexing/javascript/javascript-seo-basics) developers.google.com · checked 2026-11-01
3. 03 [Fix Search-related JavaScript problems](https://developers.google.com/search/docs/crawling-indexing/javascript/fix-search-javascript) developers.google.com · checked 2026-11-01

Questions

## Asked a lot.

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

_01_ Is 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.

_02_ Does 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.

## Keep learning

[All glossary](/glossary)

[Learn React SEO Technical SEO](/glossary/react-seo) [Related Static site generation Fundamentals](/glossary/static-site-generation) [Read next Rendering Crawling and indexing](/glossary/rendering) [Do Run a free site audit Free, about two minutes](/site-audit)

Nearby in glossary
[Ideal customer profile (ICP)](/glossary/ideal-customer-profile) [Image compression](/glossary/image-compression)

More in Crawling and indexing
[Client-side rendering](/glossary/client-side-rendering) [Crawl budget](/glossary/crawl-budget) [Crawl errors](/glossary/crawl-errors) [Crawl stats report](/glossary/crawl-stats-report) [Duplicate content](/glossary/duplicate-content) [Dynamic serving](/glossary/dynamic-serving) [ETag](/glossary/etag) [Google Indexing API](/glossary/google-indexing-api) [Google Search Console](/glossary/google-search-console) [HTML sitemap](/glossary/html-sitemap) [HTTP status codes](/glossary/http-status-codes) [HTTPS](/glossary/https) [Hydration](/glossary/hydration) [Index bloat](/glossary/index-bloat) [Indexability](/glossary/indexability) [Indexing](/glossary/indexing) [IndexNow](/glossary/indexnow) [Infinite scroll](/glossary/infinite-scroll) [JavaScript SEO](/glossary/javascript-seo) [lastmod](/glossary/lastmod) [Load more button](/glossary/load-more) [Log file analysis](/glossary/log-file-analysis) [Meta refresh](/glossary/meta-refresh) [Nofollow](/glossary/nofollow)

Terms on this page
[Server-side rendering](/glossary/server-side-rendering) [Client-side rendering](/glossary/client-side-rendering) [Rendering](/glossary/rendering) [Static site generation](/glossary/static-site-generation) [JavaScript SEO](/glossary/javascript-seo) [Rendered HTML](/glossary/rendered-html) [URL Inspection tool](/glossary/url-inspection-tool)

Free · 2 minutes

## Know the term. _Now check your site._

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

[Audit my site free](/site-audit)

Free, no card 60 seconds Nobody will call you

- **46** fixes shipped without a ticket Brightpipe
- **+212%** organic clicks in 90 days Ledgerly
