Glossary
Glossary Composition API

Composition API

Also known as: script setup, <script setup>, composables, setup()
TechVue

Definition

Vue 3’s way of writing a component as functions — ref, computed, watch, lifecycle hooks — inside <script setup>, so that related logic sits together and can be lifted out into a composable (useX()) and reused across components, instead of being split across the Options API’s data, computed, methods and watch buckets

The API this repository is written in, without exception; the vue/block-order rule puts it last in a file on purpose. Its unit of reuse is the composable, which is why the glossary has state pointing at useAppearance() rather than at a store. Type inference is the quiet win: a ref<string>() is typed at the point it is declared, and defineProps<{ … }>() gives a component a typed interface without a runtime schema. The Options API still works and still ships; the Composition API is what new code is written in.

Tech

Organize by what the code is about, not by what kind of thing it is. A feature’s refs, its computed values and its watchers next to each other, and the whole thing one function call away from being reused.

Related Terms

  • a: Appearance
  • ?: Keyboard shortcuts