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

KamaZz's avatar

Inertiajs with vuex

I couldn't find any mention of the Inertiajs package with vuex, maybe I am misunderstanding the Inertiajs concept? How do I use the Store in Inertiajs?

Can you show some examples?

0 likes
3 replies
Sinnbeck's avatar

Inertia uses laravel as store. You can send data back and forth the same way you would with blade/livewire etc. It uses sessions in laravel.

piljac1's avatar

It is entirely valid to use Vuex with Inertia. It was stated multiple times by the creator itself that some tasks are better achieved using standard XHR requests. So if you need Vuex to prep some data and do some standalone API calls, go for it. As for the implementation, it is the exact same as for any Vue project (from what I can understand, it is something you have done in the past).

pkabore's avatar

Inertia Js is just linking the the two sides.

Too late but just in case someone is having the same question. You could install vuex as usual and plug it in the createApp in your app.js

import { createApp, h } from 'vue';
import { createInertiaApp } from '@inertiajs/inertia-vue3';
import {InertiaProgress} from "@inertiajs/progress";
import store from '@/store/index.js';

const appName = window.document.getElementsByTagName('title')[0]?.innerText || 'Inertia';

createInertiaApp({
    title: (title) => `${title} - ${appName}`,
    resolve: (name) => import(`./Pages/${name}.vue`),
    setup({ el, app, props, plugin }) {
        return createApp({ render: () => h(app, props) })
            .use(plugin)
            .use(store)
            .mixin({ methods: { route } })
            .mount(el);
    },
});
3 likes

Please or to participate in this conversation.