redux-simple-localstorage

1.0.2 • Public • Published

redux-simple-localstorage

Ridiculously simple implementation for serialising the entire Redux store to local storage and retrieving it on application restart.

Installation

npm install --save redux-simple-localstorage

Usage

The module exports a single function. Call that with the localStorage key, and you get an object with a read and write method:

import ReduxLocalstorage from "redux-simple-localstorage"
const {read,write} = ReduxLocalstorage("myKey");

Now use write as a middleware and the result of read as initial state when you define your store:

import { createStore, applyMiddleware } from "redux";
import ReduxLocalstorage from "redux-simple-localstorage"
const {read,write} = ReduxLocalstorage("myKey");
 
import rootReducer from "./reducers/index";
import initialState from "./initialstate";
 
const store = applyMiddleware(write)(createStore)(rootReducer, read() || initialState);

License

MIT

/redux-simple-localstorage/

    Package Sidebar

    Install

    npm i redux-simple-localstorage

    Weekly Downloads

    43

    Version

    1.0.2

    License

    MIT

    Last publish

    Collaborators

    • moomba