talira

redux-persist

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

open sourceMITfree

redux-persist saves a Redux store to storage as its state changes and restores it into the store when the app starts. You wrap the root reducer with persistReducer and call persistStore, and Redux Toolkit needs no extra setup. localStorage and sessionStorage ship with it, and other storage engines plug in, such as AsyncStorage for React Native, IndexedDB and the filesystem. You choose which keys are saved, can nest persisted reducers, transform state on the way in and out, and run versioned migrations when the stored state's shape changes. It's maintained again: version 7, in beta, needs Redux 5 or Redux Toolkit 2.

Problems it solves

  • keep my Redux state after the user reloads the page
  • save a React Native app's Redux store to AsyncStorage between launches
  • migrate saved Redux state when I change the shape of my store

Features

  • saves and restores a Redux store with persistReducer and persistStore
  • localStorage and sessionStorage built in, with pluggable storage engines
  • allow and block lists for which keys are saved, and nested persisted reducers
  • versioned migrations for stored state

Limitations

  • Version 7 is in beta and needs Redux 5 or Redux Toolkit 2; 6.x keeps its own docs.1

Alternatives

The same job

These do what redux-persist does.

  1. Redux A JS library for predictable global state management
  2. Zustand Bear necessities for React state
  3. Jotai Atomic state management for React
  4. Reselect Library for memoized selector functions, commonly used with Redux

Compare redux-persist with the top 3