svelte-persistent

github | npm

ridiculously simple svelte writable persistence: SvelteKit first, with Svelte support

npm i -D svelte-persistent

Local:

Session:

import {
    localStore, sessionStore
} from '$lib/index';

// key, default value if none loaded.
const local = localStore('content', 'local');
const session = sessionStore('content', 'session');

You can use any serializable into JSON object, not just strings. The input above is bound to a number, but the store is a string.

View this page's source