The example of redux-persist
Just few lines of code in src/store.js will store your app state in storage(eg: localStorage)
const store = createStore(rootReducer, compose(
applyMiddleware(thunk, logger),
autoRehydrate(),
devTools({ hostname: 'localhost', port: 5678 })
));
persistStore(store, { storage: localForage });
Then, run the below command to start demo, and visit http://localhost:3000/
npm start
Open Chrome DevTools -> Application -> IndexedDB, you will see all your app states was be stored in storage(IndexedDB):
Then, open the DevTools Console, you will see how to restore your local storage to app state