Quick start

Getting started with the Nuxt Composition API.

Quick start

  1. First, install @nuxtjs/composition-api:

yarn add @nuxtjs/composition-api
npm install @nuxtjs/composition-api --save
  1. Enable the module.

    nuxt.config.js
    {
      buildModules: [
        '@nuxtjs/composition-api/module'
      ]
    }
    

    Note that using buildModules requires Nuxt >= 2.9. Just add it to your modules if you're on a lower version.

  2. You're good to go!

  • The module automatically installs @vue/composition-api as a plugin, so you do not need to enable it separately.

  • For convenience, this package also exports the @vue/composition-api methods and hooks, so you can import directly from @nuxtjs/composition-api.

  • For better IDE auto-complete when using script setup, follow these instructions.