Error: Hydration failed because the initial UI does not match what was rendered on the server
The HTML rendered on the server differs from the first client render, so React (Next.js/Remix) can’t attach to it.
Hydration failed because the initial UI does not matchText content does not match server-rendered HTMLThere was an error while hydratingHydration failed because the server rendered HTML didn't match the client Meaning
Server-side rendering requires the first client render to produce identical markup. Values that differ between server and browser — dates, random IDs, window/localStorage, locale formatting — or invalid HTML nesting cause mismatches.
Common causes
- Rendering
Date.now(),Math.random()or locale-dependent formatting - Reading
window,localStorageor media queries during render - Invalid nesting (
<div>inside<p>,<a>inside<a>) - Browser extensions modifying the DOM
- Different data on server vs client
⚡ Quick fix
- Move browser-only values into
useEffect(render a placeholder first) - Fix invalid HTML nesting
- Use
suppressHydrationWarningonly for unavoidable text like timestamps - Render client-only components with
dynamic(() => import(...), { ssr: false })in Next.js
Detailed fix by platform
React
- Client-only value after mount:jsx
function LocalTime({ iso }) { const [text, setText] = useState(''); // same on server and first client render useEffect(() => setText(new Date(iso).toLocaleString()), [iso]); return <time dateTime={iso}>{text}</time>; }
How to diagnose
- Diff — Which text/element differs (dev overlay shows it)?
- Browser APIs — window/localStorage/Date used in render?
- HTML — Invalid nesting?
- Extensions — Reproduce in a clean profile
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- async Client Component Error: async/await is not yet supported in Client Components, only Server Components.
- Can't resolve 'fs' Module not found: Can't resolve 'fs' (Next.js / webpack 5)
- Dynamic server usage Error: Dynamic server usage: Route /x couldn't be rendered statically because it used `cookies`
Most viewed in React
- No QueryClient set Error: No QueryClient set, use QueryClientProvider to set one
- Module parse failed Module parse failed: Unexpected token. You may need an appropriate loader to handle this file type
- useNavigate outside Router Error: useNavigate() may be used only in the context of a <Router> component.
Other ways to find it
Where this error sits
Origin: On your device. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 15 Oct 2026