UNPKG

@sv-use/core

Version:

A collection of Svelte 5 utilities.

21 lines (20 loc) 753 B
type LocalStateOptions<T> = { /** Defaults to `JSON.stringify`. */ serialize?: (value: T) => string; /** Defaults to `JSON.parse`. */ deserialize?: (value: string) => T; /** If the key is present in local storage, override that value or not. */ overrideDefault?: boolean; }; /** * A state that is synced with local storage. * @param key The key to use in local storage. * @param value The initial value of the state. * @param options Additional options to customize the behavior. * @returns A reactive `current` property. * @see https://svelte-librarian.github.io/sv-use/docs/core/local-state */ export declare function localState<T>(key: string, value: T, options?: LocalStateOptions<T>): { current: T; }; export {};