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

TheFriendlyHacker's avatar

Vuex: accessing Vuex outside of a Vue component

Typically, with Vuex, you can access the Vuex store from within a component like this:

// in the Vue component
created() {
    let user = this.$store.getters.user;
}

But how do I access the Vuex store outside of a component? For example, with vue-resource, you can use Vue.http.get('/path') to use vue-router anywhere in the application. Is there a way to do the same with Vuex? Something like Vue.store.getters.user?

0 likes
3 replies
TheFriendlyHacker's avatar
Level 6

I found the answer...it's pretty simple actually.

You can access the store like this:

// some JS file
import store from './../store'; // path to your Vuex store

let user = store.getters.user;
// do stuff with user
3 likes
rameezrami's avatar

I am working on VUEX with multiple modules

This returns only the initial store value. not the changed value

I want to get the store value at the time of the helper function call. anyone having the same problem?

Callis's avatar

Hi @rameezrami,

Could you share how you did this? I tried importing store to an API .js file but the store value outputs undefined.

import store from './store';

Thanks for your response.

Please or to participate in this conversation.