Vue3 Get App Instance

Posted on  by admin
In this article, we will start by looking at how the app initialization code works in Vue 2 apps.

Then we’ll see what drawbacks it has and how those are eliminated with the new initialization syntax used in the 3rd version of the Vue framework.

Let’s start with the current way of doing initialization in Vue 2.

Usually, in the src/main.js file, we’re bootstrapping the app by calling a new Vue as a constructor for creating an application instance. This application instance will be serving all the logic throughout the lifetime of our SPA. That all works well, and for about 3 years, we’ve been using this syntax to bootstrap our Vue apps.

However, in Vue 3 the initialization code syntax has changed.

Let’s have a look at the new syntax first and then take a look at the benefits of using it. In Vue 3, we have a dedicated createApp function to do just that. The createApp function takes a root component (App.vue) as an argument and returns a Vue app instance.

tony19tony19
97.9k0

Not the answer you're looking for? Browse other questions tagged vue.js or ask your own question.