Skip to content
landingpageprompts

Accessibility & QA · CC BY 4.0

Diagnose a Next.js hydration mismatch

Identify the specific cause of a server/client mismatch and request a minimal code fix.

By ai-prompt-library-team

Download prompt

Copies include creator credit and license links.

The prompt

I'm getting a React hydration mismatch in a Next.js app. Diagnose the root
cause and give me a minimal fix.

Console error:
{exact_error_text}

Component(s) involved:
{component_source}

Diagnose which category this falls into before proposing a fix:
1. Non-deterministic render (Date.now(), Math.random(), or similar, executed
   during render instead of after mount)
2. Browser-only API accessed during server render (window, localStorage,
   navigator without a typeof window guard or a useEffect)
3. Invalid HTML nesting causing the browser to silently reparent elements
   (e.g. <div> inside <p>, <a> inside <a>)
4. Server/client data mismatch (data fetched differently or at a different
   time on server vs. client, e.g. a cookie-dependent value read
   inconsistently)
5. Third-party script or extension mutating the DOM before hydration
   (explain if this is actually not fixable in app code)

State which category applies and why, based on the specific error and code
shown — don't just list all five as possibilities. Then give the minimal
code change that fixes the root cause. Only suggest
suppressHydrationWarning if the mismatch is truly unavoidable and
intentional (e.g. rendering a live timestamp) — explain why in that case
rather than silently reaching for it as a shortcut.

Source & permission

Original prompt in Awesome AI Prompt Library ↗

ai-prompt-library-team. Licensed under Creative Commons Attribution 4.0. Read the source license.

Changes: Prompt text unchanged. Extracted from the source document; title and usage guidance added by LandingPagePrompts.

You may share and adapt this prompt, including commercially, under its license. Retain the creator credit, source and license links, and identify your changes. No creator endorsement is implied.

Browse all community prompts →