@vue/composition-api and @nuxtjs/composition-api were critical bridges that enabled Composition API syntax in Vue 2 and Nuxt 2 projects before native support existed. @vueuse/integrations is a modern utility collection designed for Vue 2.7+ and Vue 3, providing pre-built composables for third-party libraries. While the first two packages solve framework compatibility issues for legacy systems, the latter focuses on enhancing developer productivity in maintained environments.
Understanding the evolution of Composition API support is critical when managing Vue ecosystems. @vue/composition-api and @nuxtjs/composition-api were essential tools during the Vue 2 era, while @vueuse/integrations represents the modern standard for utilities in Vue 3 and Vue 2.7+. Let's break down how they differ in setup, usage, and long-term viability.
@vue/composition-api brings Composition API to Vue 2 versions prior to 2.7.
setup, ref, reactive, and other APIs.// @vue/composition-api: Plugin installation
import Vue from 'vue';
import VueCompositionAPI from '@vue/composition-api';
Vue.use(VueCompositionAPI);
@nuxtjs/composition-api extends Composition API support specifically for Nuxt 2.
setup.// @nuxtjs/composition-api: Nuxt module config
// nuxt.config.js
export default {
buildModules: ['@nuxtjs/composition-api/module']
}
@vueuse/integrations provides utilities for Vue 2.7+ and Vue 3.
// @vueuse/integrations: Direct import
import { useAxios } from '@vueuse/integrations/useAxios';
import axios from 'axios';
@vue/composition-api requires manual plugin registration.
setup.// @vue/composition-api: Main entry
import Vue from 'vue';
import App from './App.vue';
import VueCompositionAPI from '@vue/composition-api';
Vue.use(VueCompositionAPI);
new Vue({ render: h => h(App) }).$mount('#app');
@nuxtjs/composition-api uses Nuxt's module system.
buildModules in your config file.// @nuxtjs/composition-api: Component usage
export default defineComponent({
setup() {
const { app } = useContext();
// Access Nuxt context safely
}
})
@vueuse/integrations requires no global setup.
// @vueuse/integrations: Composable usage
export default {
setup() {
const { data, loading } = useAxios('/api/users');
return { data, loading };
}
}
@vue/composition-api relies on standard Vue 2 instance properties.
this in Options API or setup return.// @vue/composition-api: Standard setup
export default {
setup() {
const count = ref(0);
return { count };
}
}
@nuxtjs/composition-api provides specific hooks for Nuxt context.
useContext, useStore, and useRoute abstract Nuxt 2 internals.setup.// @nuxtjs/composition-api: Nuxt context
export default defineComponent({
setup() {
const { store } = useContext();
const user = computed(() => store.state.user);
return { user };
}
})
@vueuse/integrations focuses on external service state.
// @vueuse/integrations: External state
export default {
setup() {
const { data, isFinished } = useAxios('https://api.example.com/data');
return { data, isFinished };
}
}
@vue/composition-api is legacy for Vue 2 < 2.7.
// Migration: Vue 2.7+ or Vue 3 (No plugin needed)
import { ref } from 'vue';
export default {
setup() {
const count = ref(0);
return { count };
}
}
@nuxtjs/composition-api is legacy for Nuxt 2.
// Migration: Nuxt 3 (Native support)
// components/Example.vue
<script setup>
const { $store } = useNuxtApp();
const user = computed(() => $store.state.user);
</script>
@vueuse/integrations is actively maintained.
// Modern Standard: VueUse Integrations
import { useAxios } from '@vueuse/integrations';
export default {
setup() {
const { data } = useAxios('/api/data');
return { data };
}
}
| Feature | @vue/composition-api | @nuxtjs/composition-api | @vueuse/integrations |
|---|---|---|---|
| Target Version | Vue 2.0 β 2.6 | Nuxt 2 | Vue 2.7+ & Vue 3 |
| Primary Goal | Polyfill Composition API | Nuxt 2 Context Support | Third-Party Integrations |
| Setup Required | Yes (Vue.use) | Yes (Nuxt Module) | No (Import only) |
| Maintenance | Legacy / EOL | Legacy / Maintenance Mode | Active |
| New Projects | β Avoid | β Avoid | β Recommended |
@vue/composition-api and @nuxtjs/composition-api were vital during the transition from Vue 2 Options API to Composition API. They allowed teams to adopt modern patterns before the core framework supported them. However, with Vue 2 reaching End of Life and Nuxt 3 stabilizing, these packages are now legacy tools. Use them only to keep existing systems running while you plan a migration.
@vueuse/integrations is the forward-looking choice. It assumes you are on a supported Vue version and helps you connect your app to the wider ecosystem without reinventing the wheel. It reduces boilerplate for common tasks like HTTP requests, focus management, and authentication.
Final Thought: If you are starting fresh, build on Vue 3 or Vue 2.7+ with @vueuse/integrations. Reserve the older packages strictly for maintaining existing Vue 2 or Nuxt 2 codebases until migration is complete.
Use this for modern Vue 3 or Vue 2.7+ applications that need reliable integrations with external libraries like Axios, Focus Trap, or JWT. It is actively maintained and works seamlessly with the native Composition API.
Select this solely for legacy Vue 2 projects running versions below 2.7. It polyfills the Composition API for older Vue 2 cores. For Vue 2.7+ or Vue 3, this package is unnecessary because the API is built-in.
Choose this only if you are maintaining an existing Nuxt 2 project that cannot yet migrate to Nuxt 3. It provides access to Nuxt context within the Composition API. Do not use this for new projects, as Nuxt 3 includes native support.
This is an add-on of VueUse, providing integration wrappers for utility libraries.
npm i @vueuse/integrations
useAsyncValidator β wrapper for async-validatoruseAxios β wrapper for axiosuseChangeCase β reactive wrapper for change-caseuseCookies β wrapper for universal-cookieuseDrauu β reactive instance for drauuuseFocusTrap β reactive wrapper for focus-trapuseFuse β easily implement fuzzy search using a composable with Fuse.jsuseIDBKeyval β wrapper for idb-keyvaluseJwt β wrapper for jwt-decodeuseNProgress β reactive wrapper for nprogressuseQRCode β wrapper for qrcodeuseSortable β wrapper for sortableFor better tree-shaking result, import functions from submodules, for example:
// Don't
import { useAxios } from '@vueuse/integrations'
import { useAxios } from '@vueuse/integrations/useAxios'
MIT License Β© 2019-PRESENT Anthony Fu