Nuxt · NUXT0061

Use explicit useState keys in exported composables

Finds Nuxt state code that should use the supported explicit usestate key in exported composables pattern instead.
NUXT0061vite-doctor/nuxthydrationwarnSuggestion

Run this rule

pnpm nuxt doctor --rules nuxt/state/prefer-explicit-usestate-key-in-exported-composables

Why it matters

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.

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)
}
Copyright © 2026