import { useCartStore } from '~/stores/cart'; export default defineNuxtPlugin(() => { const cartStore = useCartStore(); const storageKey = cartStore.getStorageKey(); cartStore.hydrateFromStorage(localStorage.getItem(storageKey)); cartStore.$subscribe( () => { localStorage.setItem(storageKey, cartStore.toStoragePayload()); }, { detached: true } ); });