Dlurak / svocal

Localstorage With The Power Of Svele Stores
https://dlurak.github.io/svocal/
Mozilla Public License 2.0
1 stars 0 forks source link
localstorage svelte sveltekit

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!