hydration-guardian

Ensures zero-mismatch integrity between server-rendered HTML and client-side React trees. Use when debugging hydration errors, fixing text content mismatches, handling browser extension DOM pollution, implementing selective hydration with Suspense, using the React 19 use() hook for deterministic server-to-client data bridges, or applying Next.js use cache for data drift prevention. Use for hydration mismatch, SSR, hydrateRoot, suppressHydrationWarning, onRecoverableError, two-pass rendering.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "hydration-guardian" with this command: npx skills add oakoss/agent-skills/oakoss-agent-skills-hydration-guardian

Hydration Guardian

Overview

Ensures zero-mismatch integrity between server-rendered HTML and client-side React trees. Covers hydration error diagnosis, selective hydration via Suspense boundaries, deterministic data bridges with the React 19 use() hook, 'use cache' for eliminating data drift, two-pass rendering for client-only content, React 19's single-diff hydration error reporting for pinpointing exact mismatches, and automated validation of rendered DOM state.

When to use: Debugging hydration mismatch errors, fixing text content mismatches, handling browser extension DOM pollution, implementing deterministic data bridges, optimizing SSR/client hydration performance, setting up error monitoring with onRecoverableError.

When NOT to use: Client-only React applications without SSR, static sites without hydration, API-only backends.

Quick Reference

PatternApproachKey Points
Selective hydration<Suspense fallback={...}> boundaryHydrates independently; prioritizes user interaction
Deterministic bridgeuse(serverPromise) instead of useEffectDirect server-to-client data transition (React 19)
Cache directive'use cache' in data fetchersShare exact server result with client during hydration
Two-pass renderinguseState + useEffect for client-onlyFirst render matches server; second adds client content
Client-only skipnext/dynamic with ssr: falseExclude component from server render entirely
Error monitoringonRecoverableError on hydrateRootDetect and report silent hydration recovery
Error reportingReact 19 single-diff error formatPinpoints exact mismatch location with unified diff output
Error callbacksonUncaughtError, onCaughtErrorGranular error handling on createRoot/hydrateRoot
Date/time safetyUTC normalization or server-synced contextPrevent locale-dependent hydration mismatches
Extension resilienceTest with common browser extensions activeDetect DOM pollution from translators, dark-mode tools

Hydration Error Diagnosis

Error MessageLikely CauseCorrective Action
Text content did not matchNon-deterministic render (dates, random values)Use two-pass rendering or suppressHydrationWarning
Expected server HTML to containClient renders content server did notMove client-only code to useEffect or dynamic import
Hydration failedInvalid HTML nesting (<p> inside <p>)Fix HTML structure; browsers auto-correct causing drift
Extra attributes from serverServer-only attributes not on clientEnsure attribute parity or use suppressHydrationWarning
There was an error while hydratingExtension-modified DOM or major mismatchCheck for browser extensions; verify HTML validity

Common Mistakes

MistakeCorrect Pattern
Using suppressHydrationWarning on container elementsFix the root cause; suppress only on leaf elements with unavoidable differences
Accessing window or document in the render bodyWrap client-only code in useEffect or use next/dynamic with ssr: false
Using Math.random() or new Date() without stable seedsUse UTC normalization, server-cached values, or two-pass rendering
Ignoring silent hydration recovery in productionConfigure onRecoverableError on hydrateRoot to log and monitor
Using dangerouslySetInnerHTML with server/client mismatchEnsure identical content or use a dedicated key change to force remount
Checking typeof window !== 'undefined' in renderUse two-pass rendering; the check runs on server too (it returns false)
Nesting <p> inside <p> or <div> inside <p>Fix invalid HTML nesting; browsers correct it causing server/client drift

Delegation

  • Scan rendered pages for hidden hydration warnings: Use Explore agent with Chrome DevTools to run the hydration audit script
  • Fix hydration mismatches across multiple routes: Use Task agent to isolate, correct, and verify each affected component
  • Design hydration-safe architecture for new features: Use Plan agent to select between Suspense boundaries, two-pass rendering, and cache patterns

References

  • Common Mismatches -- causes, diagnosis, and fixes for hydration mismatch errors including dates, locales, HTML nesting, and browser extensions
  • Selective Hydration -- Suspense-based selective hydration, streaming SSR, two-pass rendering, and client-only components
  • Use Cache Patterns -- data drift prevention, Next.js use cache directive, React 19 use() hook, deterministic data bridges
  • Validation Techniques -- automated DOM verification, mutation monitoring, onRecoverableError, and production hydration monitoring

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Coding

github-cli

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

tanstack-cli

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

typescript-patterns

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

tanstack-devtools

No summary provided by upstream source.

Repository SourceNeeds Review