How to access a Vuex store outside of a component in Vue.js?

Sometimes, we want to access a Vuex store outside of a component in Vue.js.

In this article, we’ll look at how to access a Vuex store outside of a component in Vue.js.

How to access a Vuex store outside of a component in Vue.js?

To access a Vuex store outside of a component in Vue.js, we can import the store and use it directly.

For instance, we write

import { store } from "./store";

store.getters.appSettings

to import the store with

import { store } from "./store";

Then we get the value of the appSettings getter with

store.getters.appSettings

Conclusion

To access a Vuex store outside of a component in Vue.js, we can import the store and use it directly.