Setup Vuex with external file

But after this make a file in the resources/assets/js called store.js then set it up as needed Here I will have one loading state

export default {
  state: {
    loading: true,
  getters: {
    loading: state => {
      return state.loading;
  mutations: {
    loading(state, loading) {
      state.loading = loading;

now import it into your app.js

import store from './store';


var app = new Vue({
  mixins: [require('spark')],
  store: new Vuex.Store(store),

That should do it. I do load some state in my resources/views/layouts/app.blade.php

        window.Laravel = {!! json_encode([
                "apiToken" => auth()->user()->api_token ?? null
            ]) !!};

Just to help with some basic stuff