redux-persist

Persist and automatically rehydrate a Redux store across sessions, with pluggable storage engines, migrations, and state reconcilers.

Library
npm
v6.0.0
12,951 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
47 /100 Fair
Development Activity 0
Maintenance 20
Community 68
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
66 /100 Good
Architecture 72
Code Quality 68
Innovation 55
Learning Curve 70

Redux Persist wraps an existing Redux reducer so its state is automatically saved to storage and restored on the next load, without changing how the rest of the app dispatches actions or reads state. It ships pluggable storage engines (localStorage/sessionStorage for web, and any AsyncStorage-compatible engine for React Native), configurable whitelist/blacklist filtering, versioned migrations for evolving state shapes, and swappable state reconcilers that control how restored state merges with a reducer’s initial state.

The library has been a staple of the Redux ecosystem since 2015, widely used on both web and React Native to bootstrap persisted state before rendering (via the bundled PersistGate component). A community-maintained ecosystem of transform packages layers on encryption, compression, and immutable-state support on top of the core serialization pipeline.

What You Get

  • persistReducer — wraps any reducer to add automatic persistence and rehydration, requiring only a key and a storage engine to get started
  • persistStore — creates a persistor object with .purge(), .flush(), .pause(), and .persist() lifecycle controls
  • Pluggable storage engines — localStorage/sessionStorage out of the box, or any object exposing getItem/setItem/removeItem (e.g. AsyncStorage for React Native)
  • Built-in state reconcilers (autoMergeLevel1, autoMergeLevel2, hardSet) controlling how restored state merges with a reducer’s initial state
  • createMigrate for versioned state migrations when a persisted shape changes between app releases
  • PersistGate React component that delays rendering children until rehydration completes
  • Nested persists, whitelist/blacklist filtering, and a transform pipeline for customizing what gets serialized

Common Use Cases

  • Keeping a logged-in user’s session or auth tokens available across browser refreshes without re-fetching from the server
  • Persisting shopping-cart or form-draft state in a web app so it survives an accidental tab close
  • Restoring app state instantly on cold start in React Native apps using AsyncStorage as the storage engine
  • Migrating a persisted state shape safely across app versions using versioned migrations instead of wiping user data
  • Selectively excluding sensitive or ephemeral slices of state (e.g. navigation, temporary UI state) from persistence via blacklist/whitelist

Under The Hood

Architecture persistReducer wraps a base reducer and intercepts a small set of internal action types (PERSIST, PURGE, FLUSH, PAUSE, REHYDRATE) rather than using Redux middleware, delegating the actual storage write to a “persistoid” object created by createPersistoid, which batches changed state keys through a throttleable interval before calling the pluggable storage engine’s setItem. persistStore creates a tiny internal Redux store purely to track per-key registration and rehydration bookkeeping, and exposes .purge()/.flush()/.pause()/.persist() by dispatching those same special action types back through the wrapped reducer — an unconventional inversion where storage side effects are triggered from reducer logic rather than middleware. State reconciliation is delegated to swappable reconciler functions, and storage engines are pluggable objects satisfying a small get/set/removeItem interface, giving reasonably clean separation between the reducer wrapper, the write-batching layer, the reconciler, and the storage engine, tempered by a few explicitly flagged unhandled edge cases in the core reducer.

Tech Stack Written in TypeScript (the large majority of the codebase, migrated from Flow in 2021), with redux as the only peer dependency and no runtime dependencies of its own. Built via tsc for commonjs and ES2015 module outputs and via Rollup (with Terser) for a UMD bundle, tests run under Ava with ts-node, mocking via Sinon and redux-mock-store, and linting/formatting via ESLint, Prettier, and a Husky/lint-staged pre-commit hook. A small React integration entry point (integration/react) ships the PersistGate component separately from the core.

Code Quality A dedicated tests directory covers the reducer state machine, persistor lifecycle, combined reducers, and flush behavior through several Ava spec files with supporting mock utilities. Configuration errors are caught explicitly in development (missing key or storage throws immediately), but storage write failures fall back to a single optional writeFailHandler with console logging in development and otherwise fail silently — there is no retry path. Naming and types are consistent throughout a well-defined types.ts, and CI runs via GitHub Actions, though the project’s own maintainers note the repo has had periods of low activity between maintenance transitions.

API Design The public surface is intentionally minimal: wrapping an existing reducer with persistReducer and calling persistStore on the resulting store is enough to get persistence with almost no boilerplate, and PersistGate removes the need to hand-write a loading gate around rehydration. Storage is abstracted behind swappable engines so the same API covers web and React Native without special-casing, nested persists allow per-slice storage/filtering rules, and a transform pipeline lets community packages add encryption, compression, or immutable-state support without touching the core. The pattern is now common (built into libraries like Redux Toolkit’s persistence helpers and Zustand’s persist middleware), so it reads as an influential, well-worn design rather than a novel one today.

Used by 8 apps in this directory

TypeScript
97%
AGPL 3.0

Bigcapital

Invoicing Finance

3,916

Self-hostable double-entry accounting platform with invoicing, inventory, multi-currency, and real-time financial reporting for small and medium businesses.

View details
90
Repo Health
77
Technical
61
Dependency
Built with
TypeScript 97%
Updated 1 weeks ago
TypeScript
98%
AGPL 3.0

Checkmate

Analytics · Devops · Monitoring

10,895

Self-hosted uptime and infrastructure monitoring with multi-protocol checks, global geo-coverage, and beautiful real-time dashboards.

View details
90
Repo Health
82
Technical
67
Dependency
Built with
TypeScript 98%
Updated 2 weeks ago
TypeScript
84%
Apache 2.0

Continue

AI Code Assistants · AI Development · Automation

36,049

Open-source coding agent for VS Code, JetBrains, and CLI with support for 30+ LLM providers.

View details
73
Repo Health
88
Technical
62
Dependency
Built with
TypeScript 84%
Updated 1 weeks ago
Python
63%
BSD 3

Flagsmith

Ab Testing Experimentation · Developer Tools · Devops

6,577

Open-source feature flagging, remote config, and A/B/multivariate testing platform for web, mobile, and server-side apps — self-host or use the hosted SaaS.

View details
90
Repo Health
82
Technical
63
Dependency
Built with
Python 63%
TypeScript 31%
Updated 1 weeks ago
Rust
65%
Other

GitButler

AI Development · Developer Tools · Devops

21,726

Git, but better — a modern version control client with stacked branches, parallel workflows, unlimited undo, and first-class support for AI-powered development.

View details
89
Repo Health
84
Technical
66
Dependency
Built with
Rust 65%
TypeScript 22%
Svelte 10%
Updated 1 weeks ago
TypeScript
94%
AGPL 3.0

Laudspeaker

Automation · Marketing

2,626

Open-source customer engagement platform for building visual, event-triggered messaging journeys across email, SMS, push, in-app, and webhooks.

View details
51
Repo Health
66
Technical
62
Dependency
Built with
TypeScript 94%
Updated 3 months ago
TypeScript
51%
Other

Mattermost

Collaboration · Devops · Team Chat

39,203

Open core, self-hosted team collaboration with chat, AI agents, voice calling, and deep DevOps integrations — all under your control.

View details
96
Repo Health
87
Technical
65
Dependency
Built with
TypeScript 51%
Go 40%
Updated 1 weeks ago
JavaScript
50%
AGPL 3.0

QRev

AI Agents · CRM

363

Open source AI-first sales platform that replaces Salesforce with autonomous agents handling prospecting, outreach, and lead management at scale.

View details
38
Repo Health
68
Technical
63
Dependency
Built with
JavaScript 50%
Python 28%
TypeScript 14%
Updated 8 months ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers