Stop Rebuilding UI

Shadcn.io is not affiliated with official shadcn/ui

React useReadLocalStorage Hook

React useReadLocalStorage hook for read-only localStorage access. Cross-tab sync, TypeScript generics, SSR safe.

Read localStorage values reactively without writing. useReadLocalStorage subscribes to a storage key and returns the current value with live updates. Syncs across browser tabs via storage events. Also listens for custom local-storage events from useLocalStorage for same-tab sync. Returns null if key is missing. Custom deserializer support for complex types. TypeScript generics for type-safe returns. Handles JSON parsing errors gracefully with console warnings. Perfect for reading shared state, feature flags, user preferences, or any localStorage data you do not own. SSR safe with configurable initialization.

React useReadLocalStorage Hook preview

Scroll to load preview

Installation

FAQ

Was this page helpful?

Sign in to leave feedback.