Skip to content

Instantly share code, notes, and snippets.

@moaoa
Created September 16, 2023 16:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moaoa/94e006a11e9a42412cd1c588bc79312c to your computer and use it in GitHub Desktop.
Save moaoa/94e006a11e9a42412cd1c588bc79312c to your computer and use it in GitHub Desktop.
presist vuex store in local storage
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