use_local_storage
Reactive LocalStorage.
LocalStorage stores data in the browser with no expiration time. Access is given to all pages from the same origin (e.g., all pages from “https://example.com” share the same origin). While data doesn’t expire the user can view, modify and delete all data stored. Browsers allow 5MB of data to be stored.
This is in contrast to use_session_storage which clears data when the page session ends and is not shared.
Usage
See use_storage for more details on how to use.
Installation
cargo add leptos-use-storage
Options
UseStorageOptions
Options for use with use_local_storage_with_options, use_session_storage_with_options and use_storage_with_options.
Options for use_storage_with_options.
The filter is a type parameter so that the debounce and throttle code is only compiled into your app if you use it.
Every option is set with a builder method of the same name, e.g. UseStorageOptions::default().on_error(...). See also the API docs.
on_error
Type: Arc<dyn Fn(UseStorageError<E, D>) + Send + Sync>
listen_to_storage_changes
Type: bool
initial_value
Type: MaybeRwSignal<T>
filter
Type: F
delay_during_hydration
Type: bool
Delays the reading of the value from storage by one animation frame during hydration.
This ensures that during hydration the value is the initial value just like it is on the server
which helps prevent hydration errors. Defaults to false.