Nuxt · Hydration & SSR
NUXT0061Use explicit useState keys in exported composables
Finds Nuxt state code that should use the supported explicit usestate key in exported composables pattern instead.
vite-doctor/nuxthydrationwarnSuggestion
Why it happens
Compiler-generated useState() keys depend on the composable's source location. An explicit key keeps state identity stable when an exported composable moves or changes.
Fix
Use the Nuxt-supported explicit usestate key in exported composables pattern instead.
Example
Use explicit useState keys
Before
export function useCounter() {
return useState(() => 0)
}
After
export function useCounter() {
return useState('counter', () => 0)
}
Verify the fix
Run only this rule after editing so the report stays focused on the diagnostic you are closing:
pnpm nuxt doctor --rules nuxt/state/prefer-explicit-usestate-key-in-exported-composables