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

Flex's avatar
Level 4

Vuex is not working on Laravel 10 and Vue Js 3

working with Laravel 10 and Vue Js 3 project as well and Installed Vuex 4 with the project. I have following comA.vue file

<template>
    <div>
        <h1>I am com A and the counter is : {{ $store.state.counter  }}</h1>
    </div>
</template>

usecom.vue

import { createStore } from 'vuex';

const store = createStore({ state : { conuter : 1000, deleteModalObj : { showDeleteModal: false, deleteUrl : '', data : null, deletingIndex: -1, isDeleted : false,

    }, 
    user: false, 
}, 
getters: {
    getCounter(state){
       return state.conuter
    }, 
    // getDeleteModalObj(state){
    //     return state.deleteModalObj
    // }
    

   

},

mutations: {
    changeTheCounter(state, data){
        state.conuter += data
    }, 
    // setDeleteModal(state, data){
    //     const deleteModalObj = {
    //         showDeleteModal: false, 
    //         deleteUrl : '', 
    //         data : null, 
    //         deletingIndex: -1, 
    //         isDeleted : data,
    //     }
    //     state.deleteModalObj = deleteModalObj
    // },
    // setDeletingModalObj(state, data){
    //     state.deleteModalObj = data
    // },
    // updateUser(state, data){
    //     state.user = data
    // },
}, 



actions :{
    changeCounterAction({commit}, data){
        commit('changeTheCounter', data)
    }
}

});

export default store;

but in my usecom.vue file comA counter not working and comA.vue enconted following error messege Property '$store' does not exist on type '{ $: ComponentInternalInstance; $data: {}; $props: Partial<{}> & Omit<{} & VNodeProps &

how to fix this problem here?

0 likes
8 replies
shadkamel's avatar

if you are using inertiajs, then actually, you don't need vuex for your project, you must use shared data , and then which $this.store is causes this error ?

shadkamel's avatar

@Flex so i think that is your problem, use vite it is faster and better for all aspects. in both laravel and vue js

shadkamel's avatar

@Flex you can try pinia, it is more simple and easy to use, and supported by vuejs themself

Please or to participate in this conversation.