> For the complete documentation index, see [llms.txt](https://coldbox-elixir.ortusbooks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://coldbox-elixir.ortusbooks.com/v3/vuejs_integration.md).

# Vue.js Integration

ColdBox Elixir lets you work with `.vue` files out of the box.

You will begin by installing Vue.js via npm: `npm install vue`. This will add `Vue` as a dependency for your project in your project's `package.json` and into the `node_modules` directory. The following is the `package.json` you should use when integrating with Vue.js:

**package.json**

```javascript
{
  "private": true,
  "devDependencies": {
    "coldbox-elixir": "3.0.0",
  },
  "dependencies": {
    "vue": "^2.0.0"
  }
}
```

Then create your normal JavaScript and Vue components in your `resources/assets/js` folder.

```javascript
const elixir = require("coldbox-elixir");

module.exports = elixir(mix => {
    mix.vue("app.js");
});
```

Your `App.js` can look like this:

**resources/assets/js/App.js**

```javascript
import Vue from "vue";

new Vue({
  el: "#app",
  data: {
    message: "Hello, world!"
  }
});
```

And you can import any components following the same relative path of the `resources/assets/js` folder.

You can also use the optional `.vue` syntax which allows you to co-locate your template, styles, and scripts in a single-file component.

**resources/assets/js/App.js**

```javascript
import Vue from "vue";
import Profile from "./components/Profile.vue";

new Vue({
  el: "#app",
  components: { Profile }
});
```

**resources/assets/js/components/Profile.vue**

```
<template>
  <div class="profile">
    {{ name }}
  </div>
</template>

<script>
export default {
  data () {
    return {
      name: "Luis Majano"
    };
  }
};
</script>

<style>
.profile {
    background: #eee;
    border: 1px solid #aaa;
    border-radius: 2em;
    margin: 2em auto;
    min-height: 150px;
    padding: 2em;
    width: 300px;
}
</style>
```

You would then use this in your ColdBox layout or view like so:

```markup
<div id="app">
    <profile></profile>
</div>
<script src="/includes/js/App.js"></script>
```

Any style blocks in your `.vue` components will be extracted as well to the same directory as your javascript file as a css file. For example, if you were compiling `mix.vue( "app.js" )` Elixir would generate a `includes/js/app.css` file containing the css for the style blocks used in that entrypoint.

> Note: there are some drawbacks with style blocks in Vue components and Elixir. if you are creating multiple entry points with multiple `mix.vue` calls, any style blocks in shared components will be duplicated in each of the css files. Additionally, because Elixir is already extracting other css files, style blocks in Vue components are always extracted. For these reasons, we recommend using other approaches to managing your css with Vue components and Elixir.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://coldbox-elixir.ortusbooks.com/v3/vuejs_integration.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
