I am trying to set/get key value pairs to localStorage with vueuse's useStorage in a pinia store. It set's and gets the value fine but after a refresh it resets the value to the default value.
Here is my store
import { useStorage } from '@vueuse/core';
export const useMyStore = defineStore(
'my-store',
() => {
const myKV = useStorage('mykv', false);
return {
myKV,
};
},
);
And here is the component
<script setup lang="ts">
const myStore = useMyStore();
</script>
<template>
<div>
<span>{{ myStore.myKV }}</span>
<button @click="myStore.myKV = !myStore.myKV">Toggle</button>
</div>
</template>