0Pricing
Vue Academy · Lesson

What Makes a Good Composable

Naming convention (useName), encapsulating reactive state, returning refs not raw values.

What Is a Composable

A composable is a function that uses Vue Composition API to encapsulate and reuse stateful logic. It is the Vue 3 answer to mixins - cleaner, explicit, and type-friendly.

The use Prefix Convention

By convention composables are named with a use prefix: useCounter, useFetch, useMouse. This instantly signals that the function holds reactive logic.

function useDarkMode() { /* ... */ }
function usePagination() { /* ... */ }

All lessons in this course

  1. What Makes a Good Composable
  2. useCounter: A Simple Composable
  3. useFetch: Async Data Composable
  4. VueUse: The Composable Library
← Back to Vue Academy