This middleware makes it really easy to sync your writable store to localStorage. It wraps any writable with any data type and provided a key which is a string and writes back to localStorage on change. It also loads the store with the last value saved in localStorage.


Check your local storage, on changing name value, name key should update!


<script lang="ts">
import { storage } from "svelte-legos/middlewares";
import { writable } from "svelte/store";

const name = storage(writable(""), "name");

<input bind:value={$name} />