Server/client branch in render
- Typical code
if (typeof window !== 'undefined')inside JSX logic- Check
- Search render paths for
window,document,localStorage
A React or Next.js hydration mismatch. Find the changing render, bad HTML nesting or CDN rewrite behind it and fix it with useEffect or ssr false.
"Text content does not match server-rendered HTML" is React error 425, a hydration mismatch: the first client render produced different output than the HTML the server sent. Common causes are Date.now() or Math.random() in render, typeof window branches, invalid tag nesting, browser extensions, and CDNs that rewrite HTML. Make the first render deterministic, or move the difference into useEffect.
Four quick questions, then a straight answer.
From your answers, this is quietly costing you traffic and nobody has the hours to chase it. Scaplet finds every affected page, drafts the fixes and tracks how AI answers mention you.
A data platform shipped 46 fixes without a ticket.
This looks handled. Re-check after a redesign, a migration or a big content push; that is when it breaks.
Your site is small and you have the time. Work through the steps on this page, starting with the pages that get the most traffic.
hydrateRoot docs are blunt: it "expects the rendered content to be identical with the server-rendered content. You should treat mismatches as bugs and fix them."if (typeof window !== 'undefined') inside JSX logicwindow, document, localStorageDate.now(), new Date(), Math.random() in rendertoLocaleString() without a fixed locale and time zone, which differs between server and usertimeZone<div> or <ul> inside <p>, <a> inside <a>, <button> inside <button>curl output through the CDN and straight from originformat-detection meta tag shown belowReact has a family of messages for this. Error 425 reads "Text content does not match server-rendered HTML." Error 418 reads "Hydration failed because the server rendered %s didn't match the client. As a result this tree will be regenerated on the client." The fix is the same idea for both.
# Replace the origin address with yours
curl -s https://example.com/page > cdn.html
curl -s -H "Host: example.com" https://ORIGIN_IP/page -k > origin.html
diff cdn.html origin.html | head -n 40In development React and Next.js log which element or text differed. Note whether it names text, an attribute or a tag.
Open View Page Source (the server HTML) and compare with the Elements panel (the hydrated DOM). The difference is your mismatch.
Test in a private window with extensions disabled, then fetch the page from origin and through the CDN and diff the bodies.
Comment out time, random and window usage until the error stops, then restore pieces one at a time.
import { useState, useEffect } from 'react'
export default function App() {
const [isClient, setIsClient] = useState(false)
useEffect(() => {
setIsClient(true)
}, [])
return <h1>{isClient ? 'This is never prerendered' : 'Prerendered'}</h1>
}import dynamic from 'next/dynamic'
const NoSSR = dynamic(() => import('../components/no-ssr'), { ssr: false })
export default function Page() {
return (
<div>
<NoSSR />
</div>
)
}<time dateTime="2016-10-25" suppressHydrationWarning /><meta
name="format-detection"
content="telephone=no, date=no, email=no, address=no"
/>useEffect keeps the server HTML stable and fixes the mismatch at the sourcessr: false is quick for widgets that depend on browser APIsuseEffect or under ssr: false is not in the server HTML, so crawlers that do not run JavaScript will not see itsuppressHydrationWarning hides the warning without fixing text that differs4 questions people ask next, answered from the sources on this page.
React says to treat mismatches as bugs. In development it warns, and error 418 states that the affected tree will be regenerated on the client.
Browser extensions that change the HTML before React loads are a documented cause, as are locale-dependent date formatting and iOS data detection.
Yes. The Next.js docs list an incorrectly configured edge or CDN that modifies the HTML response, such as Cloudflare Auto Minify, as a cause.
Only for a single element that must differ, like a timestamp. It works one level deep and React will not patch mismatched text content.
Run the free audit, then approve the fixes. Every change can be undone.