All Projects → andsala → svelte-persistent-store

andsala / svelte-persistent-store

Licence: MIT license
Persist your svelte store in localStorage or sessionStorage

Programming Languages

typescript
32286 projects

Labels

Projects that are alternatives of or similar to svelte-persistent-store

wallet-adapter
Modular TypeScript wallet adapters and components for Solana applications.
Stars: ✭ 964 (+995.45%)
Mutual labels:  svelte
pittsburgh-steps
A short visual ode to Pittsburgh's many outdoor steps, using data from WPRDC.
Stars: ✭ 23 (-73.86%)
Mutual labels:  svelte
svelte-multiselect
Keyboard-friendly, accessible and highly customizable multi-select component
Stars: ✭ 91 (+3.41%)
Mutual labels:  svelte
svelte-sortable-list
A svelte 3 component that implements a list with animated drag-n-drop functionality.
Stars: ✭ 103 (+17.05%)
Mutual labels:  svelte
svelte-cloudinary
Cloudinary SDK for Svelte
Stars: ✭ 13 (-85.23%)
Mutual labels:  svelte
i18n-unused
The static analyze tool for finding, marking and removing unused and missing i18n translations in your JavaScript project
Stars: ✭ 76 (-13.64%)
Mutual labels:  svelte
portfolio-svelte
My over-complicated personal site. A place to show off work and writing, and a place to try weird stuff.
Stars: ✭ 24 (-72.73%)
Mutual labels:  svelte
emojimix
🤖 emojimix implemented in Svelte 🤖
Stars: ✭ 24 (-72.73%)
Mutual labels:  svelte
s-date-range-picker
📅 A date range picker built with Svelte
Stars: ✭ 13 (-85.23%)
Mutual labels:  svelte
svelte-typewriter
A simple and reusable typewriter effect for your Svelte applications
Stars: ✭ 204 (+131.82%)
Mutual labels:  svelte
year-in-dev
A web tool tool that displays a summary of your DEV.to blog's stats!
Stars: ✭ 22 (-75%)
Mutual labels:  svelte
svelte-loader-hot
Webpack loader for svelte components with HMR support
Stars: ✭ 22 (-75%)
Mutual labels:  svelte
form-validation
FormValidation, the best validation library for JavaScript
Stars: ✭ 137 (+55.68%)
Mutual labels:  svelte
svelte-template-hot
Copy of official Svelte template with added HMR support
Stars: ✭ 61 (-30.68%)
Mutual labels:  svelte
svelte-adapter-deno
A SvelteKit adapter for Deno
Stars: ✭ 152 (+72.73%)
Mutual labels:  svelte
vite-plugin-webfont-dl
⚡ Webfont Download Vite Plugin - Make your Vite site load faster
Stars: ✭ 69 (-21.59%)
Mutual labels:  svelte
ModalFileManager
A file manager built using Svelte and Wails. It has hotkeys that are modal just like Vim and NeoVim.
Stars: ✭ 21 (-76.14%)
Mutual labels:  svelte
svelte-undoable
Memento design pattern in Svelte
Stars: ✭ 39 (-55.68%)
Mutual labels:  svelte
svelte-material
Modular and customizable Material Design UI components for Svelte.js
Stars: ✭ 30 (-65.91%)
Mutual labels:  svelte
Sveno
A tool to convert any React JS app to Svelte app 🚀
Stars: ✭ 56 (-36.36%)
Mutual labels:  svelte

svelte-persistent-store

npm version Build Status

Persist your svelte store in localStorage or sessionStorage.

Install

npm install --save svelte-persistent-store

Usage

Persist to localStorage

import { writable, readable, derived } from 'svelte-persistent-store/dist/local';
// or
import { local } from 'svelte-persistent-store';
const { writable, readable, derived } = local;

const count = writable('count', 0);

count.set(1);

Persist to sessionStorage

import { writable, readable, derived } from 'svelte-persistent-store/dist/session';
// or
import { session } from 'svelte-persistent-store';
const { writable, readable, derived } = session;

const count = writable('count', 0);

count.set(1);

API

key parameter is used by localStorage and sessionStorage to store and retrieve the value.

The Storage interface specification only allows string values, therefore this library serializes stored values as JSON.

// writable store of `T` values
store = writable(key: string, value: T, (set: (value: T) => void) => () => void)
// readable store of `T` values
store = readable(key: string, value: T, (set: (value: T) => void) => () => void)
// store of `U` values derived from store `a` of `T` values
store = derived(key: string, a, callback: (a: T, set: (value: U) => void) => void | () => void, initial_value: U)
// store of `U` values derived from stores `[a, ...b]` of `[T1, T2, ...]` values
store = derived(key: string, [a, ...b], callback: ([a: T1, ...b], set: (value: U) => void) => void | () => void, initial_value: U)
// get value from a store (re-export from 'svelte/store')
value: any = get(store)
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].