0Pricing
Vue Academy · Lesson

Why Composition API?

Limitations of Options API, logic reuse problem, Composition API advantages.

The Two Ways to Write Vue

Vue 3 gives you two styles for authoring component logic: the Options API and the Composition API. Both produce the same end result, but they organize code very differently.

Understanding the trade-offs helps you pick the right tool and read existing codebases with confidence.

How the Options API Organizes Code

The Options API splits a component into fixed sections: data, computed, methods, watch, and lifecycle hooks. Each piece of a feature lives in a different section.

For one small feature you might touch four separate blocks of the file.

export default {
  data() {
    return { count: 0 }
  },
  computed: {
    doubled() { return this.count * 2 }
  },
  methods: {
    increment() { this.count++ }
  }
}

All lessons in this course

  1. Why Composition API?
  2. setup() Function and Reactive Variables
  3. ref vs reactive: When to Use Each
  4. Computed and Watch in Composition API
← Back to Vue Academy