Hydration Fix Skill (Nuxt 4)
This skill is exclusively for diagnosing and fixing hydration issues in Nuxt 4 (SSR/CSR DOM, JS, CSS mismatches). It is analysis-first and proposal-only until the user explicitly approves the fix.
When to Use
- •A warning/error mentions hydration mismatch, SSR/CSR mismatch, or "content does not match".
- •A component or route renders differently server vs client.
- •UI glitches appear only after hydration.
- •The user asks to fix hydration in Nuxt 4 (even without logs).
Mandatory behavior (proposal-first)
- •Do not change code immediately.
- •Analyze first: identify likely causes and where to inspect.
- •Propose fixes: provide a ranked list and ask for approval before edits.
- •If details are missing, ask targeted questions.
- •Stop after the proposal unless the user explicitly approves a fix.
Required context checks
Before proposing a fix:
- •Read
docs/ARCHITECTURE.mdfor project constraints. - •Read
docs/DESIGNSYSTEM.mdfor styling rules. - •Read
docs/PRODUCT.mdif UX/content decisions are involved.
Investigation checklist (Nuxt 4)
Use this checklist and report findings:
Common causes
- •Non-deterministic render data (Date/Time/Random/UUID).
- •Locale/timezone differences.
- •Client-only APIs during SSR (
window,document,matchMedia,localStorage). - •CSS that depends on client state (color mode, viewport size).
- •DOM from 3rd-party libs that mutates on mount.
- •
v-if/v-forconditions that differ between server and client. - •Async data arriving at different times server vs client.
- •Dynamic class/style generation that depends on client-only values.
Nuxt/Vue patterns to validate
- •
useAsyncDatavsonMounteddata usage. - •
useHeadwith client-only values. - •Color mode or theme class toggle timing.
- •
ClientOnlyusage where needed. - •
defineNuxtPluginside effects that run on server. - •
watchEffectorcomputedproducing client-only output.
Styling mismatch cases
- •SSR-generated class lists differ from client.
- •
backdrop-filter/CSS features toggled conditionally. - •CSS variables initialized in browser only.
Preferred solutions (ranked)
When proposing fixes, prioritize:
- •Make render deterministic (seed, stable data, same locale/timezone).
- •Move client-only logic behind
process.client/import.meta.client. - •Use
ClientOnly/Suspensefor truly client-only UI. - •Defer client-only styling changes until mounted.
- •Use VueUse composables to avoid direct browser APIs and to keep SSR-safe behavior.
Nuxt 4-specific guidance
- •Prefer
useAsyncData/useFetchoveronMountedfor SSR data. - •Use
useStatefor shared SSR-safe state. - •Avoid client-only
Date.now()in templates; compute on server or after mount. - •For color mode: ensure class changes do not affect SSR HTML mismatch.
- •For 3D/Canvas: gate with
ClientOnlyand lazy-load if needed.
Output format (always use)
- •Symptoms recap (1-2 lines)
- •Likely causes (ranked list)
- •Proposed fixes (ranked list + file targets)
- •Questions (only if needed)
- •Ask for approval ("Want me to apply option X?")
Do not do
- •Do not edit files before approval.
- •Do not introduce new libraries unless explicitly requested.
- •Do not move code between apps (
frontend↔cms).
Invocation
This skill is manual only due to disable-model-invocation: true.
Use it by calling /hydration-fix-skill in chat.
Example proposal structure
Symptoms: Hydration mismatch in HeroHeader.vue (text differs SSR/CSR).
Likely causes:
- •
Date.now()used in template. - •
useWindowSize()in computed classes.
Proposed fixes:
- •Move time output behind
onMounted+ placeholder SSR text. - •Replace direct
windowusage with VueUse and guard withimport.meta.client.
Questions:
- •Is the timestamp meant to be server-accurate or purely client?
Approval:
- •Want me to apply fix 1 or 2?