@wippy-fe/pinia-persist
v0.0.20
Published
Pinia plugin for auto-persisting stores via the Wippy state preservation API.
Readme
@wippy-fe/pinia-persist
Pinia plugin for auto-persisting store state via the Wippy state preservation API. State survives iframe destruction and is restored on next mount.
Installation
npm install @wippy-fe/pinia-persistPeer dependencies: @wippy-fe/proxy, pinia
Quick Start
import { createPinia } from 'pinia'
import { createWippyPersist, preloadWippyState } from '@wippy-fe/pinia-persist'
// Preload state before creating stores (optional but recommended)
await preloadWippyState()
const pinia = createPinia()
pinia.use(createWippyPersist())How it works
- Hooks into Pinia's
$subscribeto detect state changes - Debounces writes to
state.set()to avoid excessive saves - Flushes pending state on
@visibility:false(page going to background) - Restores state on store creation via
state.getAll() - Each store's state is scoped to the page/artifact UUID automatically
