[Vuejs]-Does anyone know how to install the @nuxtjs/composition-api in nuxt3?

0👍

The @nuxtjs/composition-api package backported Composition API functionality to Vue2, however this is no longer require as Nuxt3 is built on top of Vue3; To resolve this issue, you should be able to remove the package from your package.json and as a dependency, and use the associated Composition API functions (ref, computed, etc) without requiring any imports, as Nuxt is now handling this via auto-imports, which you can read more about with the below link:

https://nuxt.com/docs/guide/concepts/auto-imports

Hope this helps you migrate to Nuxt 3 🙂

0👍

I’m also migrating a Nuxt 2 project to Nuxt 3 with the @nuxtjs/composition-api package.

One error is that vue 3 deleted the set and del functions so in order to migrate to 3 you must replace those with a working solution.
Remove usage of Vue.set() with a compilant Vue 3 reactivity assing.
Maybe this post can help!

Then replace all usage of @nuxtjs/composition-api with imports from

import { onMounted, computed, ref } from "@nuxtjs/composition-api"; // <-- REMOVE
import { onMounted, computed, ref } from "vue"; // <-- ADD from vue

import { useRoute } from "@nuxtjs/composition-api"; // <-- REMOVE
import { useRoute } from "#imports"; // <-- ADD Path from Nuxt 3


import { useContext } from "@nuxtjs/composition-api";
import { useNuxtApp } from "#imports"; // <-- ADD Path from Nuxt 3

Vuex

Also as bonus if you still use Vuex to handle stores you could use this package for Nuxt 3, then replace:

import { useStore } from "@nuxtjs/composition-api";
import { useStore } from "vuex";

Leave a comment