Composition API for Vues
The Vue Composition API organises component logic by feature using functions such as ref, computed and watch. With script setup, code runs at the top level of a single-file component without a returned object. Composables are functions that package reactive logic, like a mouse tracker or fetch helper, for reuse across components.
Stage: Composition and Reuse · Part of the Vue roadmap · Last reviewed 19 November 2026
What to learn in Composition API
- Write a component using script setup with props and emits
- Extract repeated logic into a composable function
- Use defineProps and defineEmits with TypeScript types
- Share state between components through a composable
- Compare the Composition API with the Options API
Composition API interview questions
What is a composable in Vue?
A composable is a function, usually named useSomething, that uses Vue's reactivity and lifecycle APIs to encapsulate stateful logic. Components call it to share behaviour such as fetching, form handling or tracking window size without mixins.
Why was the Composition API introduced?
In the Options API, logic for one feature spreads across data, methods and hooks in large components, and reuse via mixins has naming clashes. The Composition API groups related code and enables clean reuse with better TypeScript support.
Where Composition API fits in the Vue roadmap
Composition API belongs to the Composition and Reuse stage (intermediate level), which takes about 19 hours. Share logic.