Skip to content

redux-persist

Saves a Redux store to storage and restores it when the app starts.

Stars
12.9k
Forks
838
Licence
MIT
Language
TypeScript
Last update
29 days ago
Type
Library

What it is

redux-persist is a library for Redux apps. It saves your app's state to storage as it changes, such as localStorage on the web or AsyncStorage in React Native, and loads it back into the store when the app starts. You wrap your root reducer with persistReducer and create a persistor with persistStore.

  • Keep a logged-in user's settings after the browser is closed and reopened
  • Save shopping cart or form contents across app launches
  • Skip saving temporary keys by passing a denylist function
  • Reset state on logout and flush it to storage right away with persistor.flush()

Great for

  • Web developers who want Redux state to survive a page reload
  • React Native developers who need state saved with AsyncStorage
  • Teams already using Redux or Redux Toolkit who want persistence without a new state system
  • Apps that need to choose which top-level state keys are saved

Not ideal for

  • Projects that do not use Redux, since the library is built for Redux stores
  • Apps that need to store very large or sensitive data without extra work, because the README points to recipes like encryption rather than providing it by default
  • Teams that cannot take time to decide how stored state merges with initial state, since the README says every app must make this choice
Step-by-step guide: how to use redux-persistInstall, first run, examples, tips and FAQs

How to get it

  1. 1

    Install with a package manager

    You'll need: Node.js · Redux or Redux Toolkit (v7 docs require Redux 5 or Redux Toolkit 2)

    Install from npm

    npm install redux-persist
  2. 2

    Run it

    • Install redux-persist and your storage engine, if it is not the default
    • Create a persistConfig with a key, version and storage
    • Wrap your root reducer with persistReducer and pass the result to configureStore
    • Call persistStore(store) to create the persistor
    • Optionally wrap your React root in PersistGate to wait for state to load
  3. 3

    Get the most out of it

    • Use allowlist or denylist, including a function, to control which keys are saved
    • Use nested persists for finer control below the top level
    • Add migrations with version numbers when your state shape changes
    • Read the state reconcilers doc before shipping to choose how stored and initial state merge
    • Use useRehydrated(persistor) if you do not want to block rendering with PersistGate

Downloads

Strengths

  • Drop-in setup: wrap the root reducer and call persistStore, with the README stating Redux Toolkit needs no extra setup
  • Works with many storage backends, including localStorage, sessionStorage, AsyncStorage, IndexedDB and the filesystem
  • Supports migrations so stored state can be upgraded when its shape changes

Trade-offs

  • You must choose a state reconciler strategy, and the default merges only one level deep, so it needs careful reading before shipping
  • The README shows v7 is in beta and the stable release shown is v6.0.0, so APIs may change for v7 users
  • Stored data needs care during changes; the README says to read CONTRIBUTING before touching stored data formats

How it compares

ProjectStarsTypeLevelUpdatedBest for
redux-persist (this)12.9kLibraryintermediate29 days agoWeb developers who want Redux state to survive a page reload
redux61.4kLibraryintermediate16 days agoDevelopers building larger front-end apps where many components share the same data
zustand58.9kLibrarybeginner15 days agoReact developers who want simpler shared state than Redux
immer29kLibrarybeginner6 days agoJavaScript developers who find hand-written immutable updates verbose or error-prone
redux-saga22.4kLibraryintermediate12 days agoReact or other frontend developers already using Redux who need to manage async logic
reselect19kLibraryintermediate9 days agoRedux users who want to derive data from a minimal store without recomputing it on every render

Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.