redux-store-persist

0.1.1 • Public • Published

redux-store-persist

Persist a Redux Store to localStorage.

Installation

$ npm install redux-store-persist

Usage

import persistStore from 'redux-store-persist'

const { loadState, persistState } = persistStore('storageKey')

const store = createStore(
  reducer,
  loadState() // Initialize store with saved state, if it exists
)

persistState(store) // Save state to localStorage on change

Persisting just a part of a store

persistState(store, (state) => {

  // Pass a callback that returns the parts of your store that you want to
  // persist to localStorage

  return {
    auth {
      user: state.auth.user
    }
  }
})

Package Sidebar

Install

npm i redux-store-persist

Weekly Downloads

0

Version

0.1.1

License

MIT

Last publish

Collaborators

  • restlessbit