The Composition API is a set of APIs for authoring Vue components with imported functions instead of declaring options. It is an umbrella term covering the Reactivity API — ref() and reactive() — for directly creating reactive state, computed state, and watchers; lifecycle hooks such as onMounted() and onUnmounted() for hooking into the component lifecycle programmatically; and provide() and inject() for dependency injection. It is a built-in feature of Vue 3 and Vue 2.7; for older Vue 2 versions, use the officially maintained @vue/composition-api plugin. In Vue 3 it is primarily used together with the <script setup> syntax in single-file components. Despite an API style based on function composition, it is not functional programming: it builds on Vue's mutable, fine-grained reactivity paradigm, whereas functional programming emphasizes immutability. Its primary advantage is clean, efficient logic reuse through composable functions, which solves the drawbacks of mixins, the primary logic-reuse mechanism of the Options API, and has enabled community projects such as VueUse. Scope: Vue 3. Reviewed October 4, 2026.
Composition API: function-based component logic
Document v1 · published by Koskamo editorial · updated 2026-10-04
Source and provenance
- Original source
- vuejs.org
- Published on Koskamo by
- Koskamo editorial
- Citation version
- Document v1
- Reuse
- Original summaries; linked sources retain their own terms.