Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

nolros's avatar
Level 23

Import my app init vue file

Is the best approach in Vue to import my own init (app or main or whatever you want to call it )

Per the example:

  1. I import the init.vue with import init from './init.vue'
  2. I then init with render: h => h(init)

Question:

Is this a best practice is I didnt want app.js to be more core js file or is there a best practice? Why would I want to do that ?

Why this approach?

Lets say I build multiple mini apps and I want to deploy at a customers site I dont need to screw with their app.js , instead I just load the init / main into their app.js with 2 lines of code and it runs.

JS - init.vue & app.js examples

init.vue

<template>
    <div>
        <p>stuff</p>>
    </div>
</template>

<script>

    export default {

    };

</script>

app.js

require('./bootstrap');

window.Vue = require('vue');

// 1. importing init file
import init from './init.vue'

const app = new Vue({
    el: '#app',
    // 2. rendering / executing it
    render: h => h(init)
});
0 likes
1 reply
freeccboy's avatar

your question is very confusing I can not decipher what is the question

what I understand is that if you make multiple mini applications you can create many components, so they are called init1.vue init2.vue

you can also use vue router to give a route to each component

Please or to participate in this conversation.