Vue · Composables

VUE0026Name setup-bound composables with use

Finds exported functions that need a component setup context but are not named like composables.

Why it happens

Vue composables are named with a use prefix so readers know a function must run synchronously during setup or inside another composable. Lifecycle hooks, inject(), provide(), getCurrentInstance(), and other composables fail or leak when a plainly named helper is called from an event handler, timer, or module scope.

Fix

Rename the function with a use prefix and call it only from setup or another composable. Functions that only create ref(), reactive(), or computed() state, only read Nuxt app context such as useNuxtApp() or useState(), define*/create* factories, Pinia stores, and on*/provide*/inject* helpers are not reported.

Example

Name setup-bound functions as composables

Before

// app/composables/cart.ts
export function cartState() {
  const items = useState<CartItem[]>('cart', () => [])
  onMounted(() => hydrateCart(items))
  return { items }
}

After

// app/composables/cart.ts
export function useCart() {
  const items = useState<CartItem[]>('cart', () => [])
  onMounted(() => hydrateCart(items))
  return { items }
}

Verify the fix

Run only this rule after editing so the report stays focused on the diagnostic you are closing:

pnpm vite-doctor . --framework vue --rules vue/composables/require-use-prefix
Copyright © 2026