# Fix JS and hydration errors

- Check 08.10 · JavaScript and HTML rendering · Critical
- Source: https://checklist-seo-geo.com/en/javascript-html-rendering/fix-js-hydration-errors
- Find the JavaScript errors and hydration mismatches that empty or alter your pages for Googlebot, then fix them on Next.js, Nuxt, Angular or WordPress.
- Updated on 2026-11-25
- Licence: CC BY 4.0. Credit “Checklist SEO & GEO” with a link to https://checklist-seo-geo.com/en/javascript-html-rendering/fix-js-hydration-errors.
- Plugin checklist-seo-geo: 1.3.1 · https://github.com/maximegaul/checklist-seo-geo

## In short

An unhandled JavaScript error can stop the script that displays the content; a hydration error occurs when the HTML sent by the server does not match what the framework then computes in the browser. In both cases, what Googlebot sees after rendering may differ from what you think you are publishing: missing text, absent links, a blank page, replaced content. This check consists of collecting these errors, from visitors as well as from Googlebot, and fixing their cause rather than hiding them.

## Why it matters

Google renders pages with a recent version of Chromium, but under particular conditions its documentation details: it declines permission requests (camera, geolocation), clears local storage and cookies between page loads, and does not support WebGL or WebSocket and WebRTC connections. Code that assumes these features are available crashes for Googlebot while working fine for you. If the content depends on that code, Google indexes an incomplete page, or even classifies it as a soft 404.

Hydration is the step where React, Vue, Angular or Svelte attach their logic to the HTML rendered by the server. React asks you to treat any mismatch as a bug: at best it slows the page down, at worst event handlers end up attached to the wrong elements. Vue tries to fix the DOM by throwing away and recreating the mismatched nodes, at the cost of performance. Angular reports a DOM mismatch error.

For SEO, the risk is twofold. The initial HTML, read by crawlers that do not execute JavaScript, and the final DOM, read by Google, diverge: different prices, dates, titles or links. And the framework's corrections cause visual shifts and long tasks that degrade CLS (Cumulative Layout Shift) and INP (Interaction to Next Paint).

## What it improves

- **Indexing**: the expected content and links are present in the HTML rendered by Google.
- **Consistency across crawlers**: the initial HTML and the final DOM say the same thing, for Google as well as for AI crawlers that read the raw HTML.
- **Core Web Vitals**: fewer recreated nodes, fewer shifts and long tasks.
- **Reliability**: failures that are invisible in development show up in your logs before they cost you indexed pages.
- **Rankings**: no direct effect; the effect comes through complete indexing and page experience.

## How to check

1. **Browser console**: open the developer tools, Console tab, filter on “Errors” and reload the page. In development, Next.js shows hydration mismatches in an overlay; Angular shows the number of hydrated components and nodes; Vue and React show a detailed warning. In production, React shows minified messages with a link to `react.dev/errors`.
2. **For Googlebot**: in Search Console, [URL Inspection](https://search.google.com/search-console?action=inspect), “Test live URL”, “View tested page”, then “More info”: the JavaScript console output and the resources that failed to load are listed there. The Rich Results Test gives the same information without access to Search Console.
3. **Lighthouse**: the best practices audit flags errors logged to the console.
4. **Comparison**: check that a key text on the page (price, title, date) is identical in `curl -s https://example.com/page/` and in the rendered DOM. See [compare initial HTML and rendered DOM](https://checklist-seo-geo.com/en/javascript-html-rendering/compare-initial-html-rendered-dom).

Compliant result: no red errors in the console, neither on your side nor in Google's live test, no hydration warnings in development, and identical values in the initial HTML and the rendered DOM.

## How to implement

### Before you start

First collect errors in production, including Googlebot's. Google suggests listening for the `error` event; add `unhandledrejection` for rejected promises, which are common with `fetch`:

```js
const reportError = (payload) => {
  navigator.sendBeacon('/api/js-errors', JSON.stringify({ ...payload, url: location.href, userAgent: navigator.userAgent }));
};

window.addEventListener('error', (event) => {
  reportError({ message: event.message, source: event.filename, line: event.lineno, column: event.colno });
});

window.addEventListener('unhandledrejection', (event) => {
  reportError({ message: String(event.reason) });
});
```

Place this script as early as possible in the `<head>`. Syntax errors in a file are not reported this way: test the production build as well. An error tracking service such as Sentry does the same thing, with grouping and source maps. Then filter the entries whose user agent contains `Googlebot`.

Then address the causes, which are almost always the same:

| Cause | Fix |
|---|---|
| Invalid HTML nesting (`<div>` inside `<p>`, `<a>` inside `<a>`, table without `<tbody>`) | Fix the template: the browser rewrites this HTML before hydration |
| `window`, `localStorage`, `matchMedia` or `typeof window` in the render | Read these values after the component has mounted |
| Date, time, time zone, random number | Compute on the server and pass the value down, or display after mounting |
| Third-party script, A/B test or tag manager that modifies the DOM before hydration | Load it after hydration, or exclude the affected area |
| CDN or proxy that rewrites the HTML | Disable the rewriting for the site |
| iOS Safari turning phone numbers and addresses into links | `format-detection` tag |
| Feature missing for Googlebot (WebGL, permissions, storage, WebSocket) | Detect the feature and provide a fallback |

For the last case, feature detection is enough:

```js
const canvas = document.createElement('canvas');
const hasWebGL = Boolean(canvas.getContext('webgl2') || canvas.getContext('webgl'));

if (hasWebGL) {
  startViewer3D();
} else {
  showStaticGallery();
}
```

Do not hide mismatches with the warning suppression options: they are only meant for a value that is inevitably different, such as a timestamp.

### Next.js

Versions: Next.js 15 and 16 (App Router and Pages Router).

Next.js documents the causes above and three solutions, to be used in this order.

**Render differently after mounting**: the first client render reproduces the server HTML, and the browser-specific value comes afterwards.

```tsx
'use client';

import { useEffect, useState } from 'react';

export function LocalTime({ iso }: { iso: string }) {
  const [label, setLabel] = useState(iso.slice(0, 10));

  useEffect(() => {
    setLabel(new Date(iso).toLocaleString('fr-FR'));
  }, [iso]);

  return <time dateTime={iso}>{label}</time>;
}
```

**Do not prerender a purely client-side component** (map, editor, widget), using `dynamic(() => import('./carte'), { ssr: false })`, called from a client component. Keep this for elements with no content to index: whatever they display no longer exists in the initial HTML.

**Accept an unavoidable mismatch** on a single element with `suppressHydrationWarning`. The attribute only works one level deep, and React then does not fix the text.

For iOS Safari, declare format detection in the metadata of `app/layout.tsx`:

```tsx
export const metadata = {
  formatDetection: { telephone: false, email: false, address: false },
};
```

With the Pages Router, put `<meta name="format-detection" content="telephone=no, email=no, address=no" />` in the `<Head>` component of `pages/_document.tsx` instead.

### Nuxt

Versions: Nuxt 3.17 and later, including Nuxt 4 (Vue 3.5).

Nuxt recommends composables that share state between server and client:

- `useState` for a random value or a value computed once, instead of `Math.random()` in `setup`;
- `useCookie` instead of `localStorage` for a preference that changes the render;
- `useFetch` or `useAsyncData` for data, which pass the server's result on to the client;
- `onMounted` to initialize libraries that touch the DOM;
- `<ClientOnly>` for a purely client-side component, with fallback content if the area matters for SEO;
- `<NuxtTime>` for dates.

In `nuxt.config.ts`, disable Safari's format detection:

```ts
export default defineNuxtConfig({
  app: {
    head: {
      meta: [{ name: 'format-detection', content: 'telephone=no, date=no, email=no, address=no' }],
    },
  },
});
```

Since Vue 3.5, the `data-allow-mismatch` attribute tolerates an unavoidable mismatch on a specific element.

### Angular

Hydration is enabled with `provideClientHydration()` in the application's providers. Angular requires the server DOM and the client DOM to match exactly, whitespace and comments included:

- replace direct DOM manipulation (`innerHTML`, `appendChild`, `document.querySelector`) with Angular's APIs;
- declare `<tbody>` explicitly in tables;
- use `ngSkipHydration` on a component's host only as a last resort: it disables hydration for that component and its children.

In development mode, the console shows hydration statistics; the Angular DevTools extension shows the state of each component.

### Astro

Versions: Astro 5 to 7.

Only islands (components with a `client:*` directive) hydrate. A mismatch in a React, Vue or Svelte island is fixed as in those frameworks. `client:only` skips server rendering: the component does not exist in the initial HTML, so keep it for elements with no content to index.

Since Astro 7, the compiler no longer fixes invalid HTML nesting and rejects unclosed tags: a `<div>` inside a `<p>` is sent as is, then rewritten by the browser. Fix the template.

### Laravel

Versions: Laravel 11 to 13, Livewire 3 and 4, Inertia 2 and 3.

With Inertia and server-side rendering enabled, restart the SSR process on every deployment (`php artisan inertia:start-ssr` under a process supervisor): a process still running the old bundle produces HTML that differs from the JavaScript served to browsers. With Livewire, the HTML is rendered by the server; errors mostly come from Alpine or third-party scripts, visible in the console.

### WordPress

Versions: WordPress 6.4 and later; Health Check & Troubleshooting plugin 1.7 (its listing states it was tested up to WordPress 6.6).

Errors rarely come from WordPress itself:

- **Optimization plugins**: deferring, delaying or combining JavaScript sometimes breaks the load order (jQuery called before it is loaded). Disable the options one at a time, then exclude the faulty script from optimization.
- **Plugin conflicts**: the Health Check & Troubleshooting plugin, published by the WordPress.org community team, lets you disable plugins and the theme for your own session only, without affecting the public site.
- **Content loaded by a script** (reviews, tabs, sliders): check that it is present in the initial HTML.

Clear the caches after each attempt.

### Shopify

Versions: Online Store 2.0 themes, Shopify theme editor, November 2026.

Errors mostly come from apps. In the theme editor, the App embeds section lets you disable them one by one; test in an unpublished duplicate theme. Scripts added to `theme.liquid` by old, uninstalled apps sometimes remain in place: remove those that cause a 404 error or an exception in the console.

### Cloudflare

Versions: Cloudflare dashboard, all plans, November 2026.

Features that rewrite the HTML or the way scripts load can create hydration mismatches: Email Address Obfuscation, Rocket Loader ([speed optimization](https://dash.cloudflare.com/?to=/:account/:zone/speed/optimization)). On a server-rendered React, Vue or Angular site, disable them for the domain, or for the affected paths with a configuration rule. Purge the cache afterwards.

## Common mistakes

- **Fixing by adding `ssr: false` everywhere**: the mismatches disappear, but the content leaves the initial HTML.
- **`suppressHydrationWarning` on an entire container**: it only works one level deep and hides the symptom.
- **Testing only in development**: minification, third-party scripts and the CDN only exist in production.
- **Ignoring rejected promises**: a failed `fetch` without a `catch` leaves an empty area with no visible error.
- **Assuming Googlebot has local storage**: it is cleared on every page load, like cookies.
- **Letting an A/B test modify the DOM before hydration**: random mismatches that are hard to reproduce.

## Frequently asked questions

### Does a hydration error prevent indexing?

A hydration error does not necessarily prevent indexing, but it can change what Google indexes. The framework fixes the DOM in its own way: Google sees the corrected version, while crawlers without JavaScript read the server HTML. The two versions may then differ on a price, a date or a link. An unhandled JavaScript error is more serious: it can stop the display and leave Google with an empty page.

### How can I see the JavaScript errors Googlebot runs into?

To see the JavaScript errors Googlebot runs into, open URL Inspection in Search Console, run “Test live URL”, then “View tested page” and “More info”: the JavaScript console output and the resources that failed to load are listed there. The Rich Results Test shows the same information. For continuous monitoring, log errors on the client side and filter those whose user agent contains Googlebot.

### Should I disable server rendering to get rid of hydration errors?

No: disabling server rendering removes the error by also removing the content from the initial HTML, which makes it invisible to crawlers that do not execute JavaScript. Fix the cause instead: invalid HTML nesting, a value computed differently on the server and on the client, a script that modifies the DOM too early. Keep client-only rendering for components with no content to index, such as an interactive map or an editor.

### Why does the page work for me but not for Googlebot?

Googlebot renders pages under different conditions from an ordinary browser: it declines permission requests, clears local storage and cookies between page loads, does not support WebGL or WebSockets, and may ignore caching headers. Code that assumes a saved preference, geolocation or a WebSocket connection fails for it. Detect these features before using them and provide a fallback.

## Resources

- [Google Search Central: Fix Search-related JavaScript problems](https://developers.google.com/search/docs/crawling-indexing/javascript/fix-search-javascript?hl=en)
- [React: hydrateRoot](https://react.dev/reference/react-dom/client/hydrateRoot)
- [Next.js: React hydration error](https://nextjs.org/docs/messages/react-hydration-error)
- [Vue: Hydration mismatch](https://vuejs.org/guide/scaling-up/ssr.html#hydration-mismatch) and [Nuxt: Hydration best practices](https://nuxt.com/docs/4.x/guide/best-practices/hydration)
- [Angular: Hydration](https://angular.dev/guide/hydration)
- [MDN: unhandledrejection event](https://developer.mozilla.org/en-US/docs/Web/API/Window/unhandledrejection_event)

Next steps: [test rendering in Search Console](https://checklist-seo-geo.com/en/javascript-html-rendering/test-rendering-search-console), [check content loaded via API](https://checklist-seo-geo.com/en/javascript-html-rendering/check-content-loaded-via-api) and [integrate SEO tests into CI/CD](https://checklist-seo-geo.com/en/automation-quality-control/integrate-seo-performance-accessibility-tests-into-ci-cd).
