Persist Vuex state with localStorage and share between tabs.
$ npm install vuex-persisted-shared-stateor
$ yarn add vuex-persisted-shared-stateimport persistedSharedState from "vuex-persisted-shared-state";
const store = new Vuex.Store({
// ...
plugins: [
persistedSharedState({
'cart': 'SET_CART',
}),
]
});Creates a new instance of the plugin with the given mutations object and options.
Mutations can be provided like strings
{
'cart': 'SET_CART',
}or like an objects
{
'cart': {
mutation: 'SET_CART',
share: false,
defaultValue: null,
},
}The following options can be provided to configure the plugin for your specific needs:
share: Should state change be shared between browser tabs. (default: true)prefix: Prefix of the localStorage keys. (default: 'vuex-persisted-shared-state')