# Hydration failed because the server rendered HTML didn't match the client

> Canonical page (link this when citing): https://unbreakmyapp.vercel.app/fixes/nextjs-hydration-mismatch.html
> Category: Deploys | Tools: v0, Cursor | Published: 2026-10-13 | Updated: 2026-10-13

## The error

Error: Hydration failed because the server rendered HTML didn't match the client

## Why it happens

The component renders something different on the server and in the browser: dates/times, Math.random(), window/localStorage reads during render, invalid HTML nesting (a <div> inside a <p>), or browser extensions changing the DOM.

## How to fix it

1. Move browser-only values (localStorage, window, Date.now()) into useEffect.
2. Fix invalid nesting such as <div> inside <p> or <a> inside <a>.
3. Use next/dynamic with ssr:false for browser-only components.
4. Test in an incognito window to rule out extensions.

## Error codes this fixes

- `Hydration failed` (Next.js / React): https://unbreakmyapp.vercel.app/errors.html#hydration-failed

## Fix prompt (paste into Lovable, Bolt, Cursor, Replit or v0)

```text
Next.js shows 'Hydration failed because the server rendered HTML didn't match the client'. Find render-time uses of window, localStorage, Date, Math.random or locale formatting and move them into useEffect or a client-only component, fix any invalid HTML nesting, and explain which component caused it.
```

## FAQ

### Is suppressHydrationWarning a fix?

Only for single intentional mismatches like timestamps.

### Could an extension cause it?

Yes, try incognito.

## Sources (official documentation)

- [Next.js: Text content does not match server-rendered HTML](https://nextjs.org/docs/messages/react-hydration-error)

## Related fixes

- [Vercel build fails: Type error / ESLint errors (works locally)](https://unbreakmyapp.vercel.app/fixes/vercel-build-failed-type-errors.html)
- [404 NOT_FOUND when refreshing a page (React/Vite SPA)](https://unbreakmyapp.vercel.app/fixes/vercel-404-on-refresh-spa.html)
- [CORS error: blocked by CORS policy: No 'Access-Control-Allow-Origin' header](https://unbreakmyapp.vercel.app/fixes/cors-error-fetch-blocked.html)
- [Replit deploy: app not reachable / port not open](https://unbreakmyapp.vercel.app/fixes/replit-port-not-open.html)

---
Unbreak My App: free fixes for broken vibe-coded apps. https://unbreakmyapp.vercel.app/
