Vue · VUE0026

Name setup-bound composables with use

Finds exported functions that need a component setup context but are not named like composables.
VUE0026vite-doctor/vuecomposableswarnSuggestion

Run this rule

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

Why it matters

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.

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