React useLocalStorage Hook: SSR-Safe Persistent State (2026)

The user spends two minutes setting up filters on your dashboard, hits refresh, and everything resets. useState is ephemeral by design — every reload starts from scratch. The fix everyone knows is localStorage; the wiring everyone writes for it — a useState initializer that reads storage plus a useEffect that writes it back — ships at least four bugs: it crashes or mismatches under SSR, it throws on corrupted data, it desyncs across browser tabs, and two components using the same key silently drift apart.

useLocalStorage is the hook that gets all of it right. It looks exactly like useState, but the value survives reloads, serializes more than just strings, stays in sync across tabs and across components, and renders safely on the server. Everything below is the real @reactuses/core API, TypeScript-first.

Why Not Just useState + useEffect?

Here is the version that ends up in most codebases, and it's buggier than it looks: