Created
September 16, 2023 16:21
-
-
Save moaoa/94e006a11e9a42412cd1c588bc79312c to your computer and use it in GitHub Desktop.
presist vuex store in local storage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const vuexLocalStorage = new VuexPersist({ | |
key: 'sano-vuex', | |
storage: window.localStorage, // or window.sessionStorage or localForage | |
// pass the state of the store to be persisted | |
reducer: state => ({ | |
auth: state.auth, | |
lang: state.lang, | |
}), | |
}); | |
const store = createStore({ | |
strict: import.meta.env.NODE_ENV !== 'production', | |
plugins: [vuexLocalStorage.plugin], | |
modules: { | |
// .... | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment