Vue Route: Uncaught TypeError: window.Vue.use is not a function

This error happens in Vue because Vue.use() is removed. Instead, install plugins like Vue Router by passing them to app.use().

Summarize with AI

Not enough time? get the key points instantly.

If you see Uncaught TypeError: window.Vue.use is not a function when using Vue Router, you’re probably mixing Vue 2 syntax with Vue 3.

In Vue development, Vue.use() is no longer used to install plugins; instead, you create an app instance with createApp and call .use() on that instance. Here’s how to fix this common mistake.

What Causes This Error

In Vue 2, you’d add Vue Router like this:

Vue.use(VueRouter)

But in Vue 3, Vue is not a global constructor anymore. Instead, you should import createApp and install plugins on the app instance.

Correct Way to Use Vue Router in Vue 3

Here’s how to properly set up Vue Router with Vue 3:

// main.js or main.ts

import { createApp } from ‘vue’

import App from ‘./App.vue’

import { createRouter, createWebHistory } from ‘vue-router’

 

// Define your routes

const routes = [

  { path: ‘/’, component: () => import(‘./components/Home.vue’) },

  // add more routes here

]

 

// Create router instance

const router = createRouter({

  history: createWebHistory(),

  routes

})

 

// Create app instance

const app = createApp(App)

 

// Install router

app.use(router)

 

// Mount the app

app.mount(‘#app’)

Also Read: How to Disable Button in VueJS

Key Takeaway

The error Uncaught TypeError: window.Vue.use is not a function means you are attempting to use the Vue 2 plugin installation method (Vue.use()) in a Vue 3 environment. For Vue 3, always use app.use(plugin) on your application instance after creating it with createApp().

Related Resources


Resources

Insights from our engineering leaders.

Our team shares practical insights on the technologies and engineering decisions shaping enterprise software today, grounded in real client work.