What is the Vue instance and how do you create one?
Why Interviewers Ask This
This question tests conceptual clarity. Interviewers want to hear a precise, confident definition before moving to more complex Vue.js topics. It also reveals how well you can explain technical ideas to non-experts.
Answer
A Vue instance (or application instance in Vue 3) is the root of a Vue application — it connects Vue to a DOM element and manages the application's reactivity and component tree. Vue 3 (createApp): import { createApp } from "vue"; import App from "./App.vue"; const app = createApp(App); app.use(router).use(pinia); app.mount("#app");. createApp() creates a new application instance. mount() connects it to a DOM element (selector or element). The app instance provides methods: app.component(), app.directive(), app.provide(), app.use(), app.config.errorHandler. Vue 2 (new Vue): new Vue({ el: "#app", data: { message: "Hello" }, methods: { greet() {} } }). Application config (Vue 3): app.config.globalProperties.$http = axios; — adds global properties accessible in all components; app.config.errorHandler = (err) => { /* global error handler */ };; app.config.performance = true; — enable performance tracing. Multiple apps: Vue 3 supports multiple independent app instances on the same page, each with its own scope, plugins, and component tree.
Pro Tip
Before answering, structure your response: one-line definition → real-world analogy → concrete example from a project. This makes even complex Vue.js answers easy to follow.