Hydration failed because the server rendered HTML didn't match the client
Next.js "Hydration failed" error? The server and browser drew different HTML. Fix nesting, window/localStorage use and dates.
Last edited October 18, 2026
On this page
What it means in plain English
Next.js draws your page on the server first, then React takes over in the browser. If the browser's version differs, React complains.
Find a fix pack
Checklists and prompts for Supabase security, Stripe payments and deploys. Each pack is $24, or $49 for all three.
Likely causes
- Invalid HTML nesting, e.g.
<div>inside<p>,<a>inside<a>. - Using
window,localStorageortypeof windowchecks while rendering. - Showing
new Date()/random values during render. - Browser extensions changing the page.
How to fix it, step by step
- Read the error; Next.js shows the mismatching element.
- Fix bad nesting (change the outer
<p>to a<div>). - Move browser-only code into
useEffectso it runs after first render. - For components that truly can't render on the server, load them with
dynamic(() => import('./X'), { ssr: false }). - Test in an incognito window to rule out extensions.
How to check it worked
- Reload; the console shows no hydration warning.
Reading window during the server render is a common way to reach this mismatch. See window is not defined in Next.js.
Sources
Related fixes
Tool to consider: Cursor.
Find a fix pack
Checklists and prompts for Supabase security, Stripe payments and deploys. Each pack is $24, or $49 for all three.