Skip to content

Usage of Composition API

Status

Accepted.

Context

The rewrite introduced by ADR 0009 is based on Vue 3, which offers two ways of authoring components: the Options API and the Composition API. The previous Vue 2 codebase used the Options API together with Vuex.

Since a rewrite is happening anyway, it has to be decided which of the two is used.

Decision

We use the Composition API, both in components and in stores.

Consequences

  • (+) Related logic is grouped by concern instead of being spread over lifecycle hooks and options.
  • (+) Logic can be extracted into composables and reused across components and plugins.
  • (+) Type inference works without additional tooling or helper types.
  • (+) It is the style the Vue ecosystem, including Pinia, is built around.
  • (-) Contributors familiar with the Options API of the Vue 2 codebase have to learn the Composition API.