• Stars
    star
    864
  • Rank 51,079 (Top 2 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created almost 4 years ago
  • Updated 27 days ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Svelte store that persists to localStorage

npm version license codecov

svelte-local-storage-store

A Svelte store that persists to local storage. Supports changes across multiple tabs.

Installation

npm install svelte-local-storage-store

Usage

Define the store:

import { persisted } from 'svelte-local-storage-store'

// First param `preferences` is the local storage key.
// Second param is the initial value.
export const preferences = persisted('preferences', {
  theme: 'dark',
  pane: '50%',
  ...
})

Then when you want to use the store:

import { get } from 'svelte/store'
import { preferences } from './stores'

preferences.subscribe(...) // subscribe to changes
preferences.update(...) // update value
preferences.set(...) // set value
get(preferences) // read value
$preferences // read value with automatic subscription

You can also optionally set the serializer or storage type:

import * as devalue from 'devalue'

// third parameter is options.
export const preferences = persisted('local-storage-key', 'default-value', {
  serializer: devalue, // defaults to `JSON`
  storage: 'session' // 'session' for sessionStorage, defaults to 'local'
})

License

MIT

More Repositories

1

design-patterns-in-elixir

Common design patterns applied in Elixir
Elixir
598
star
2

react-hooks-in-svelte

React hook examples ported to Svelte
JavaScript
486
star
3

svelte-stripe

Everything you need to add Stripe Elements to your Svelte project
Svelte
387
star
4

commerce_billing

A payment processing library for Elixir
Elixir
176
star
5

xml_builder

Elixir library for generating XML
Elixir
163
star
6

micro-svelte-compiler

Micro Svelte compiler (naive clone)
JavaScript
111
star
7

airbadge

Svelte
87
star
8

phoenix-billing-demo

A demo of using commerce_billing with phoenix
Elixir
61
star
9

sveltekit-saas

JavaScript
59
star
10

angular-rails-api

A template for creating angular+rails apps
Ruby
53
star
11

elixir-ffi

Foreign Function Interface (FFI) for Elixir
Elixir
53
star
12

spree-faq

Frequently Asked Question extension for Spree
Ruby
46
star
13

svelte-bridge

Use your Svelte components from React & Vue.
JavaScript
42
star
14

sky-cart

Cloud-native headless shopping cart
JavaScript
36
star
15

vite-plugin-notifier

Get visual feedback that HMR completed
JavaScript
36
star
16

svelte-markdoc

Markdoc preprocessor for Svelte
JavaScript
32
star
17

supabase-active-record

ActiveRecord pattern for supabase.io
JavaScript
31
star
18

svelte-kit-ecommerce-3d

Demo using Threlte, SvelteKit and Stripe Checkout
Svelte
31
star
19

blip

A fault-tolerant and concurrent StatsD server
Elixir
30
star
20

sveltekit-stripe-subscriptions

Example of Stripe Subscriptions & PaymentElement with SvelteKit
JavaScript
30
star
21

blog-template

A markdown-style blog template for Sapper
JavaScript
28
star
22

xuber2

An example ridesharing app built with Elixir
Elixir
25
star
23

svelte-animation-store

JavaScript
24
star
24

hypersonic

A multi-player markdown editor and wiki.
Svelte
21
star
25

svelte-http-store

A Svelte store backed by the fetch API
JavaScript
19
star
26

shiki-transformer-copy-button

A Shiki Transformer that adds a Copy button
JavaScript
19
star
27

spree-html-email

HTML Formatted emails for spree
Ruby
18
star
28

tonys-apizza

POS for a pizza shop. Using SvelteKit, Prisma, and Stripe.
Svelte
17
star
29

spree-sitemap-generator

Spree Sitemap Generator
Ruby
17
star
30

bcm2835

Ruby bindings for libbcm2835
Ruby
17
star
31

glue

React hook for server-side state
JavaScript
15
star
32

spree-contact-form

Spree extension that provides a basic contact form
Ruby
14
star
33

ride_share

A clone of Uber/Lyft
Elixir
13
star
34

vertex

Store multi-tenant metrics in ClickHouse
Elixir
13
star
35

threlte-svg-extrusion

Svelte
12
star
36

svelte-kit-test-helpers

Testing utilities for SvelteKit
JavaScript
12
star
37

materialize-svelte

JavaScript
12
star
38

sprionic-demo

Demo Spree+Ionic Android/iOS App
JavaScript
12
star
39

threlte-starter

Starter template for SvelteKit + Threlte projects
Svelte
11
star
40

markdown-mail

JavaScript
11
star
41

auth-env

Load auth.js providers dynamically, by detecting environment variables
JavaScript
11
star
42

git-ssh-server

A small git/ssh server for hosting repos
JavaScript
10
star
43

phoenix_svelte_rollup_example

Elixir
10
star
44

1000experiments.dev

Svelte
10
star
45

svelte-codemirror

Svelte
9
star
46

airbadge-example

JavaScript
8
star
47

svelte-time-distance

Svelte component to display time distances in a human readable format.
JavaScript
8
star
48

combinatorics

Combinatoric utilities for Elixir
Elixir
8
star
49

transponder

Elixir
7
star
50

testing-with-sveltekit

JavaScript
7
star
51

spree-product-feed

A Spree extension that provides an RSS feed for products
Ruby
7
star
52

svelte-snowpack-template

A snowpack template for svelte with support for jest, eslint, postcss, tailwind, and rollup.
JavaScript
7
star
53

idp-experiment

JavaScript
6
star
54

httpx

A tiny concurrent & fault-tolerant HTTP server that uses pattern matching for routing
Elixir
6
star
55

nmea

Parser for NMEA compliant sensors
Elixir
6
star
56

svelte-preprocess-tailwind

Preprocess tailwind expressions with Svelte
JavaScript
5
star
57

spree_stock_notifications

Get notifications when stock is low or item goes out of stock
Ruby
5
star
58

rails-jquery-sortable

Example of a Rails app using jQuery Sortable plugin
Ruby
5
star
59

river

Example distributed key/value store using RAFT
Elixir
5
star
60

prisma-database-cleaner

Utility for cleaning Prisma databases between test runs
JavaScript
4
star
61

scrolly-snap-telling

Svelte
4
star
62

live_imu

Displays IMU data using Phoenix LiveView
Elixir
4
star
63

xuber-old

Demo of Phoenix Channels + GeoLocation API
Elixir
4
star
64

svelte-kit-with-docker

Run your SvelteKit dev environment with Docker
JavaScript
4
star
65

cloud-scaling-experiment

Shell
4
star
66

svelte-esm-loader-experimental

JavaScript
4
star
67

svelte-codemirror-test

Svelte
4
star
68

otp-talk

Elixir
4
star
69

spree-awesome-blog

Basic blog and management tools designed for Spree
JavaScript
4
star
70

guzzle

Multi-core streaming build system
Elixir
4
star
71

supabase-reactions

Svelte
4
star
72

intel8085

Assembler, Emulator and Debugger for the Intel 8085A microprocessor
C++
3
star
73

svelte-chart

Svelte
3
star
74

elixir_vite_app

Elixir
3
star
75

ecto_preloader

Preload your data efficiently with joins
Elixir
3
star
76

name-panda

JavaScript
3
star
77

sk-cookie-store-experiment

JavaScript
3
star
78

elixir_inventory_management_sample

Example inventory management system w/ Elixir
Elixir
3
star
79

snowpack-plugin-markdown

A snowpack plugin for importing markdown
JavaScript
3
star
80

electron

2
star
81

rails-templates

Rails Application Templates
Ruby
2
star
82

eagle-ruby

Ruby
2
star
83

http-shark

An HTTP proxy & GUI for recording/debugging REST API calls.
CSS
2
star
84

covid-ca

CSS
2
star
85

faas

Elixir
2
star
86

svelte-kit-pusher-example

Svelte
2
star
87

gql_commerce

JavaScript
2
star
88

svelte-checkout

JavaScript
2
star
89

octobase

Hybrid relational/document database
Erlang
2
star
90

sveltekit-redirections

JavaScript
2
star
91

tiltd

A rack daemon for tilt
Ruby
2
star
92

osm-svelte-kit-experiment

Svelte
2
star
93

http-firebase-proxy

Proxy HTTP requests, and record them in Firebase for debugging
JavaScript
2
star
94

multi_edit

Elixir
2
star
95

topaz

A distributed virtual machine that uses the actor model
JavaScript
2
star
96

sapper-data-example

JavaScript
2
star
97

use-svelte

A React hook for loading Svelte components.
JavaScript
2
star
98

wasm-ui-component-experiment

JavaScript
2
star
99

vercel-serverless-jobs

JavaScript
2
star
100

elixir-prisma

Elixir
1
star