Hydration Mismatch Error - Server and Client Render Different Content
Next.js throws a hydration mismatch error. The HTML from server doesn't match what React renders on client. Content flickers or changes when page loads.
Error: 'Warning: Did not expect server HTML to contain a
Error Messages You Might See
Common Causes
- Using client-only features (browser APIs) during server render
- Rendering different content based on window/document being defined
- Timestamps or random data rendered server-side changing on client
- Conditional rendering based on isClient flag without useEffect
- CSS-in-JS not being applied on server during build
How to Fix It
Move browser code to useEffect: useEffect(() => { setMount(true); }, [])
Use dynamic imports for browser-only components: dynamic(() => import('@/components/ClientComponent'), { ssr: false })
Don't use Date.now(), Math.random() during render - do it in useEffect
Check if typeof window === 'undefined' before using browser APIs
Real developers can help you.
You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.
Get HelpFrequently Asked Questions
When does hydration happen?
After Next.js sends HTML from server, React takes over in browser (hydration) and attaches event handlers
Why does my timestamp differ between server and client?
Server renders at build time or request time. Client renders milliseconds later. Timestamps won't match. Move to useEffect
How do I debug hydration issues?
Enable verbose logging: add suppressHydrationWarning as temporary fix, then find actual mismatch
Related Bolt Issues
Can't fix it yourself?
Real developers can help.
You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.
Get Help