Home > database >  VueUse session storage
VueUse session storage

Time:04-12

How do you specify if storage should be local or session when using VueUse? It doesn't seem to mention it in the docs https://vueuse.org/core/usestorage/

CodePudding user response:

The third argument to useStorage() specifies the storage to use. It uses window.localStorage by default.

To use session storage, pass window.sessionStorage as the storage argument:

useStorage(
  'my-storage-key',
  myInitialValue,
  window.sessionStorage,            
  • Related