Appica UIUI 1.0.0

useLocalStorage

SSR-safe state, persisted and synced across tabs.


useLocalStorage is a useState-like hook whose value persists to localStorage. It's SSR-safe, syncs across browser tabs via the storage event, and syncs other components in the same tab. A useSessionStorage variant backs onto sessionStorage.

Usage

It returns a [value, setValue, remove] tuple. setValue accepts a value or an updater function, just like useState:

Signature

Values are JSON-serialized by default. Pass a serializer/deserializer to store a raw string instead — for example a value an inline script must read without parsing JSON:

© 2026 Appica UI. A free component library, crafted by the Appica team.