# create a new vue instance
A new Vue instance is created using the `createApp` method, which is the standard approach in Vue 3. This method takes an options object as an argument, where you define the application's data, methods, components, and other configurations. The instance is then mounted to a specific HTML element in your document using the `mount` method.
Here's how to create a new Vue instance: HTML Structure.
Create an HTML file with a `div` element that will serve as the mounting point for your Vue application.
Code
``` My Vue App
```
JavaScript File (app.js).
Create a JavaScript file (e.g., `app.js`) and use `createApp` to define and mount your Vue instance.
JavaScript
``` const app = Vue.createApp({ data() { return { message: 'Hello Vue!' }; }, methods: { greet() { alert(this.message); } } }); app.mount('#app'); ```
In this example:
- `Vue.createApp({...})` initializes a new Vue application instance. - The `data` option defines reactive data properties (e.g., `message`). - The `methods` option defines functions that can be called within the application (e.g., `greet`). - `app.mount('#app')` connects the Vue instance to the HTML element with the ID `app`