Skip to content

websecret/vuex-persisted-shared-state

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vuex-persisted-shared-state

Persist Vuex state with localStorage and share between tabs.

Requirements

Installation

$ npm install vuex-persisted-shared-state

or

$ yarn add vuex-persisted-shared-state

Usage

import persistedSharedState from "vuex-persisted-shared-state";

const store = new Vuex.Store({
    // ...
    plugins: [
        persistedSharedState({
            'cart': 'SET_CART',
        }),
    ]
});

API

persistedSharedState(mutations, options = {})

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')

About

Persist Vuex state with localStorage and share between tabs.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published