# astoilkov/use-local-storage-state

React hook that persists data in localStorage

Repository: https://github.com/astoilkov/use-local-storage-state
Canonical: https://ross.abutalabs.com/products/use-local-storage-state
Language: TypeScript
License: MIT
License Family: permissive
Topics: hook, localstorage, persistent, react, usestate
Last push: 2026-07-16T11:22:25+00:00

## Health v2 (maintenance only)
Score: 90/100 (v2, computed 2026-09-03T02:20:16.233290+00:00)
- activity 92, release rhythm 81, longevity 100
- inputs: {"age_days": 2365, "days_push": 48, "days_rel": 48, "gap_med": 34, "n_releases_24m": 4}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 1231, forks 43 (observed 2026-08-28T04:04:04.199518+00:00)

## What it is
A React hook that persists component state in localStorage, acting as a drop-in replacement for useState. It supports SSR, cross-tab synchronization via the storage event, and an in-memory fallback when localStorage is unavailable.

## Use cases
- persist react state across page reloads
- sync state between browser tabs
- replace useState with localStorage-backed state
- store todos or user preferences in localStorage
- handle localStorage unavailability gracefully in react apps
- ssr-safe localStorage state in next.js

## When to choose
- you need a tiny, production-ready React hook for persistent state
- you want cross-tab/window state synchronization
- you need SSR compatibility and React 18/19 concurrent rendering support

## When to avoid
- you need persistence beyond the browser (server-side or native)
- you need to store large or complex data structures
- your project is not React-based

## Facets
- artifact type: library
- maturity: stable
- function: state-management, ui-components
- domain: frontend, web-development
- platform: browser
- tags: react-hook, localstorage, persistence, ssr, cross-tab-sync, nodejs

## Member repositories
- astoilkov/use-local-storage-state (main) score 90

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:04:04.199518+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-30T08:22:25.210983+00:00, confidence not recorded.
  - readme: https://github.com/astoilkov/use-local-storage-state (fetched 2026-08-28T04:04:04.199518+00:00, sha 5fced20f448d)
  - registry_npm: https://registry.npmjs.org/use-local-storage-state (fetched 2026-08-29T12:21:59.648855+00:00, sha 87c97a22b2a1)
- Data as of 2026-08-30T08:39:29.467469+00:00.
