Useful Tools In Vue.js Web Development
You can install this plugin using any one of the two methods:
yarn add vuex-persistedstate
npm install –save vuex-persistedstate
After the installation process is complete, the next step would be to configure this plugin to be ready for use in your Vuex store.
import Vue from ‘vue’
import Vuex from ‘vuex’
import createPersistedState from “vuex-persistedstate”;
Vue.use(Vuex)
export default new Vuex.Store({
state: {},
mutations: {},
actions: {},
modules: {},
plugins: [createPersistedState()]
At this point, all of our Vuex Store would be stored in localStorage (by default) but vuex-persistedstate comes with the option to use sessionStorage or cookies.