Guide · Vue & Nuxt

Vue 2 is end of life: how to upgrade to Vue 3

Vue 2 reached end of life on 31 December 2023. It still runs, but it no longer gets security or browser fixes, and the libraries around it are moving on. Here's how to upgrade a live Vue 2 app to Vue 3 step by step, without stopping feature work for months.

The short answer

  • Vue 2 is already end of life. The final version is 2.7.16, released in December 2023.
  • You don't need a rewrite. Vue 3 still supports the Options API, so most components only need small changes.
  • Use the migration build. @vue/compat is Vue 3 that behaves like Vue 2 and warns you about everything that has to change.
  • The libraries are usually the hard part, especially UI frameworks such as Vuetify 2, BootstrapVue and Element UI.
  • On big apps, expect surprises. In my case, the user session broke after the migration, and I rebuilt it on Pinia.

Why upgrade now

Vue 2 support timelineVue 2.7, the last minor version, was released in July 2022. Vue 2 reached end of life in December 2023. It has had no fixes since then.Vue 2.7Jul 2022End of lifeDec 2023TodayNov 2026almost 3 years without fixes
The shaded part is the time a Vue 2 app has run without security or browser fixes.

The official Vue 2 LTS page says that after end of life Vue 2 gets no more updates, “including security and browser compatibility fixes”. Your app won't stop working tomorrow, but every month adds risk:

  • Security: a vulnerability found in Vue 2 or its compiler won't be fixed. Security audits and customer questionnaires increasingly ask about end-of-life software.
  • Libraries: new versions of routers, UI kits, charts and editors target Vue 3. You end up pinned to old versions, with their own unfixed bugs.
  • Tooling: Vue CLI is in maintenance mode, and current build tools and test runners are built for Vue 3.
  • Hiring: developers who join now learn Vue 3, and older patterns slow them down.

If you truly can't upgrade yet, paid extended support exists: the LTS page points to HeroDevs. It buys time, but it isn't a plan.

Step 0: measure the job

Before estimating anything, count the patterns that will need work. Run this from the project root:

Shell · vue2-audit.sh
for pattern in \
  '\$on\(|\$off\(|\$once\(' \
  '\.sync\b' \
  'Vue\.set|Vue\.delete|\$set\(|\$delete\(' \
  'Vue\.filter|filters:' \
  '\$listeners|\$scopedSlots|\$children' \
  'beforeDestroy|destroyed\b' \
  'functional' \
  'Vue\.(component|use|mixin|directive|prototype)'
do
  printf '%-55s %s\n' "$pattern" "$(grep -rEl "$pattern" src | wc -l)"
done

cat package.json   # list every vue-* dependency and check its Vue 3 support

The number is how many files use each pattern. A few hundred .sync modifiers are a quick search-and-replace. A dozen components that rely on $children or a UI library without a Vue 3 version are where the time goes.

Dependency on Vue 2Vue 3 replacement
Vue Router 3Vue Router 4 or newer (5 is current)
Vuex 3Pinia (recommended) or Vuex 4
Vuetify 2Vuetify 3 or newer (4 is current): big changes
BootstrapVuebootstrap-vue-next
Element UIElement Plus
vue-i18n 8vue-i18n 9 or newer
@vue/test-utils 1@vue/test-utils 2
Nuxt 2Nuxt 3 or newer: a separate migration

The upgrade path

Vue 2 to Vue 3 upgrade pathFour steps: clean up on Vue 2.7, switch to the migration build, upgrade the router, store and UI libraries, then remove the compatibility layer to run plain Vue 3.1. Vue 2.7clean up first2. Migration build@vue/compat3. Librariesrouter · store · UI4. Vue 3remove compat
Each step is a normal release, so the app stays live: you can stop, ship features and continue.

This follows the order of the official migration build guide, grouped into four stages. The app stays deployable after each one.

Step 1: get ready on Vue 2.7

Vue 2.7 backported the Composition API and <script setup>. Upgrading to it first is a small change that lets new code use the Vue 3 style while the old code still runs:

  • Upgrade to vue@2.7 and remove @vue/composition-api if you used it.
  • Move old slot syntax (slot, slot-scope) to v-slot.
  • Replace event buses, filters and $children now. All three are removed in Vue 3, and the fixes work in Vue 2 too.
  • If you still use Vue CLI and Webpack, move to Vite now. It's often the biggest win of the whole migration, as the next section shows.

Webpack to Vite: the biggest win on big repos

If your app still builds with Vue CLI and Webpack, moving to Vite is often the change your team notices most. On a large repository I worked on, the build pipeline went from about 3 minutes to under 20 seconds. Every push, every pull request and every deploy got faster, which adds up to hours each week across a team.

Build pipeline time: Webpack vs ViteOn a large Vue app, the build pipeline took about 3 minutes with Webpack and under 20 seconds with Vite.Webpackabout 3 minViteunder 20 s
My own build pipeline on a large Vue app, before and after the switch. Same scale; shorter is faster.

The bigger the repository, the bigger the gain:

  • Development: Webpack bundles the whole app before the dev server starts. Vite serves your source files to the browser as native ES modules and only transforms the files a page actually requests, so start-up stays fast as the app grows.
  • Hot reload: a change replaces one module instead of rebuilding a bundle, so saving a file shows up almost instantly.
  • Production builds: current Vite builds with Rolldown and processes CSS with Lightning CSS, both written in Rust, instead of a long chain of JavaScript loaders.

Do it while you're still on Vue 2.7, with @vitejs/plugin-vue2. Then step 2 only has to swap the plugin, and you change one thing at a time:

JavaScript · vite.config.js (Vue 2.7)
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue2";
import { fileURLToPath, URL } from "node:url";

export default defineConfig({
  plugins: [vue()],
  resolve: {
    alias: { "@": fileURLToPath(new URL("./src", import.meta.url)) },
  },
});

Most of the work is in a few Webpack habits Vite doesn't share:

Webpack / Vue CLIVite
public/index.html with injected scriptsindex.html in the project root, with <script type="module" src="/src/main.js">
process.env.VUE_APP_API_URLimport.meta.env.VITE_API_URL
require("./logo.png")import logo from "./logo.png"
require.context()import.meta.glob()
import Button from "./Button"import Button from "./Button.vue": Vite needs the extension
Aliases in vue.config.jsresolve.alias in vite.config.js

Time your pipeline before and after, so you have a number to show. In my experience it's one of the easiest wins to explain to people who don't write code.

Step 2: switch to the migration build

Install Vue 3 and the compatibility build at the same version, and replace the Vue 2 template compiler:

Shell
npm install vue@3 @vue/compat@3
npm uninstall vue-template-compiler
npm install -D @vitejs/plugin-vue

Then point every import "vue" at the compatibility build and start in Vue 2 mode:

JavaScript · vite.config.js
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";

export default defineConfig({
  resolve: {
    alias: { vue: "@vue/compat" },
  },
  plugins: [
    vue({
      template: {
        compilerOptions: {
          compatConfig: { MODE: 2 },
        },
      },
    }),
  ],
});

The entry file changes from new Vue() to createApp. Global registrations move onto the app:

JavaScript · main.js, before
import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";

Vue.component("BaseButton", BaseButton);
Vue.prototype.$api = api;

new Vue({ router, store, render: (h) => h(App) }).$mount("#app");
JavaScript · main.js, after
import { createApp } from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";

const app = createApp(App);
app.component("BaseButton", BaseButton);
app.config.globalProperties.$api = api;
app.use(router).use(store).mount("#app");

Now run the app. The console fills with warnings, each with a feature ID such as GLOBAL_MOUNT or INSTANCE_EVENT_EMITTER. Fix compile-time warnings first, then work through the runtime ones one feature ID at a time. The console filter helps: search for one ID, fix it everywhere, and move on.

The breaking changes you will meet most

The full list is long, but most apps hit the same handful.

v-model and .sync on components

The prop is now modelValue and the event is update:modelValue. .sync is gone and becomes v-model with an argument:

HTML · template
<!-- Vue 2 -->
<DatePicker v-model="date" :range.sync="range" />

<!-- Vue 3 -->
<DatePicker v-model="date" v-model:range="range" />
JavaScript · DatePicker.vue
export default {
  props: ["modelValue", "range"],      // was: value
  emits: ["update:modelValue", "update:range"],
  methods: {
    pick(day) {
      this.$emit("update:modelValue", day);   // was: this.$emit("input", day)
    },
  },
};

The event bus

$on, $off and $once are removed, so new Vue() can no longer be an event bus. A tiny module replaces it, with no dependency:

JavaScript · bus.js
const handlers = new Map();

export const bus = {
  on(name, fn) {
    if (!handlers.has(name)) handlers.set(name, new Set());
    handlers.get(name).add(fn);
    return () => handlers.get(name).delete(fn);   // call to unsubscribe
  },
  emit(name, ...args) {
    handlers.get(name)?.forEach((fn) => fn(...args));
  },
};

Remember to unsubscribe in beforeUnmount. Forgotten listeners were a common memory leak in Vue 2 as well.

Filters

Filters are removed. Use a method or a computed property instead:

HTML · template
<!-- Vue 2 -->
<p>{{ price | currency }}</p>

<!-- Vue 3 -->
<p>{{ currency(price) }}</p>

Smaller ones

Vue 2Vue 3
beforeDestroy, destroyedbeforeUnmount, unmounted
Vue.set(obj, key, value)obj[key] = value (reactivity tracks it)
$listenersMerged into $attrs, which now also has class and style
$scopedSlots$slots, called as functions
@click.native@click, and declare component events in emits
() => import("./Chart.vue") as a componentdefineAsyncComponent(() => import("./Chart.vue"))
.v-enter, .v-leave CSS classes.v-enter-from, .v-leave-from (no warning, search for them)
A watcher on an array fires on mutationAdd deep: true to react to mutations
v-if and v-for on one element: v-for winsv-if wins: move it to a wrapper <template>

Step 3: upgrade the router, the store and the UI library

The router changes how it is created, and the catch-all route has a new syntax:

JavaScript · router.js
import { createRouter, createWebHistory } from "vue-router";

export default createRouter({
  history: createWebHistory(),   // was: mode: "history"
  routes: [
    { path: "/", component: Home },
    { path: "/:pathMatch(.*)*", component: NotFound },   // was: path: "*"
  ],
});

For state, Vuex 4 works with Vue 3, but Pinia is the recommended store now. You can move one Vuex module at a time:

JavaScript · stores/cart.js
import { defineStore } from "pinia";

export const useCartStore = defineStore("cart", {
  state: () => ({ items: [] }),
  getters: {
    total: (state) => state.items.reduce((sum, item) => sum + item.price, 0),
  },
  actions: {
    add(item) {
      this.items.push(item);   // no mutations, no commit()
    },
  },
});

The UI library is often the longest step. Vuetify, BootstrapVue and Element UI all changed components and props in their Vue 3 versions, and the migration build can't hide those differences, because it only covers Vue itself. Plan this per screen, and test the screens your users depend on most.

From my experience: big apps don't migrate smoothly

On a small app, the steps above can go quickly. On a large one, don't expect a smooth transition. I migrated a large monolith, and the hardest problems weren't in the components at all.

The user session was kept by a Vue 2 store library, and it broke after the migration. The console showed no warning about it, because the migration build only covers Vue itself, not the libraries around it. I rebuilt the session state on Pinia, and it has been stable since.

  • Find everything that keeps state between pages before you start: sessions, login, carts, saved filters, and any plugin that stores data in localStorage or cookies.
  • Test log in, refresh and log out by hand after every step, not only at the end.
  • Plan time for the surprises. In a monolith, a small change in one place can break a screen nobody thought was related.

Step 4: remove the migration build

When the console is quiet and no dependency still needs Vue 2 behaviour, switch components to Vue 3 mode one at a time, then all at once:

JavaScript
// one component at a time
export default {
  compatConfig: { MODE: 3 },
  // ...
};

// or the whole app, keeping only what you still need
import { configureCompat } from "vue";
configureCompat({ MODE: 3 });

Finally, remove the vue alias, the compatConfig option and @vue/compat itself. The migration build is allowed in production, with a small cost in size and speed, so you don't have to finish everything before your next release.

Tests: your safety net

  • Write a few end-to-end tests first for login, checkout or whatever earns money. They don't care which Vue version runs underneath.
  • Upgrade @vue/test-utils to v2. propsData becomes props, and mocks, stubs and plugins move under global.
  • Treat console warnings as test failures in CI once a feature ID is fixed, so it can't come back.
  • Release in small steps and watch error tracking after each one.

What doesn't migrate

  • Internet Explorer 11: Vue 3 doesn't support it. If you must support IE11, you have to stay on Vue 2.
  • Code that relies on Vue 2 internals, such as private VNode properties. Some old plugins do this and need replacing.
  • Nuxt 2: it reached end of life in June 2024 and has its own path to current Nuxt. Plan it as a separate project.
  • Server rendering with vue-server-renderer moves to @vue/server-renderer and a different setup.

FAQ

When did Vue 2 reach end of life?

On 31 December 2023. The final release is Vue 2.7.16, and Vue 2 no longer receives updates, including security and browser compatibility fixes.

Is it safe to keep running Vue 2?

The app keeps working, but new vulnerabilities in Vue 2 won't be fixed and libraries are dropping support. Paid extended support exists, but upgrading to Vue 3 is the long-term solution.

Can I upgrade from Vue 2 to Vue 3 gradually?

Yes. The migration build, @vue/compat, runs your app on Vue 3 with Vue 2 behaviour and warns about each change, so you can fix them in small releases. It can run in production while you finish.

Do I have to rewrite my components with the Composition API?

No. Vue 3 still supports the Options API. Most components need only small changes, such as renamed lifecycle hooks and the new v-model.

How long does a Vue 2 to Vue 3 migration take?

It depends mostly on your libraries and on how much code uses removed features. Count those patterns first; a UI framework without a Vue 3 version usually takes longer than Vue itself.

Is Vite faster than Webpack for Vue apps?

Usually much faster, and the gap grows with the size of the app. On a large Vue repository, my build pipeline went from about 3 minutes with Webpack to under 20 seconds with Vite.