svocal
v0.2.2
Published
Svocal combines the power of Svelte stores with localstorage.
Downloads
8
Readme
Svocal
Svocal combines the power of Svelte stores with localstorage.
Installation
npm i svocal
yarn add svocal
pnpm add svocal
bun add svocal
Usage
Import localstorage
:
import { localstorage } from 'svocal';
Then you can start using the localstorage:
const store = = localstorage('demo', 1)
const store2 = = localstorage('demo', 1)
store
and store2
both use the localstorage key demo
so when you set store store2 will also update.
store.set(42);
store2.subscribe(console.log);
Will console.log 42
This even works with different tabs, so svocal can be used to sync state between tabs and windows!