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

Amalmax's avatar

how to use Vuex in Laravel + Vue 3 project

working with Laravel + Vue 3 project. I need work with Vuex in the project. I have configure My Vuex in store.js file as following

import { createApp } from 'vue'
import { createStore } from 'vuex'

const store = createStore({
      /* state, actions, mutations */
    state : {
        counter : 1000
    }
    
    });
      
const app = createApp();
app.use(store);
app.mount("#app");

and My app.js file as following

import ViewUIPlus from 'view-ui-plus'
import 'view-ui-plus/dist/styles/viewuiplus.css'
import 'view-ui-plus/dist/styles/viewuiplus.css'
import common from './common'
import store from './store' //import store.js

createApp({
    components: {
        mainapp,
        
    }
    
}).use(router).use(ViewUIPlus).mixin(common).mount('#app');

now I am unable to how to import store.js in to the app.js file in vue 3. could you give some solution here. I need use store.js in app.js like following I know how it is in Vue 2 but need help in vue 3

.use(router).use(ViewUIPlus).mixin(common).mount('#app');
0 likes
9 replies
MohamedTammam's avatar
Level 51

The store.js file would look like

import { createStore } from 'vuex'

const store = createStore({
      /* state, actions, mutations */
    state : {
        counter : 1000
    }    
});

export default store;      

And your app.js would look like

import ViewUIPlus from 'view-ui-plus'
import 'view-ui-plus/dist/styles/viewuiplus.css'
import 'view-ui-plus/dist/styles/viewuiplus.css'
import common from './common'
import store from './store' //import store.js

createApp({
    components: {
        mainapp,
        
    }
    
}).use(router).use(store).use(ViewUIPlus).mixin(common).mount('#app');

Amalmax's avatar

@MohamedTammam I got following error message

WARNING in ./resources/js/app.js 22:19-24
export 'default' (imported as 'store') was not found in './store' (module has no exports)

Please or to participate in this conversation.