Quick start
Getting started with the Nuxt Composition API.
Quick start
-
First, install
@nuxtjs/composition-api
:
yarn add @nuxtjs/composition-api
npm install @nuxtjs/composition-api --save
-
Enable the module.
nuxt.config.js{ buildModules: [ '@nuxtjs/composition-api/module' ] }
Note that using
buildModules
requires Nuxt >= 2.9. Just add it to yourmodules
if you're on a lower version. -
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.