[Vuejs]-State is shared between multiple applications. – vuex-persistedstate

0👍

Something you can try is assigning a prefix (could be a suffix as well) that is unique to each app. Then, you can set up the getItem, setItem and removeItem methods inside createPersistedState. For example:

import { Store } from 'vuex';
import createPersistedState from 'vuex-persistedstate';

const KEY_PREFIX = 'PrefixUniqueToEachApp_';

const store = new Store({
  plugins: [
    createPersistedState({
      storage: {
        getItem: (key) => localStorage.getItem(KEY_PREFIX + key),
        setItem: (key, value) => localStorage.setItem(KEY_PREFIX + key, value),
        removeItem: (key) => localStorage.removeItem(KEY_PREFIX + key),
      },
    }),
  ],
});

Should work. You can also use it with cookies (or any other type of storage) if you wish.

Leave a comment