Registry / storage / redux-storage-engine-localstorage

redux-storage-engine-localstorage

JSON →
library1.1.4jsnpmunverified

A localStorage-based persistent engine for redux-storage, a middleware to persist a Redux store to storage backends. The engine stores the entire state tree as a JSON string under a single key in window.localStorage. Version 1.1.4 is the latest stable release, originally authored by Michael Contento and now maintained by Gunjan Soni. The package is simple but has async issues: localStorage operations block the JS thread. For full async support with IndexedDB or other backends, consider redux-storage-engine-localforage or redux-persist. Since the original project is deprecated, this fork is in maintenance mode but receives updates.

npm install redux-storage-engine-localstorage
INSTALL
IMPORT
SIG · REDUX-STORAGE-ENGI
R
redux-storage-engine-localstorage
storagejavascriptv1.1.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default export (createEngine)
✓ import createEngine from 'redux-storage-engine-localstorage'
✗ const createEngine = require('redux-storage-engine-localstorage')
The package provides a default export function; using ES module import is recommended. In CommonJS, use the default property: require('redux-storage-engine-localstorage').default
createEngine
✓ import createEngine from 'redux-storage-engine-localstorage'
✗ import { createEngine } from 'redux-storage-engine-localstorage'
There is no named export; the module exports a single default function. Named import results in undefined.
replacer/reviver usage
✓ import createEngine from 'redux-storage-engine-localstorage'; const engine = createEngine('key', replacer, reviver);
✗ const engine = createEngine('key', { replacer: myReplacer, reviver: myReviver })
replacer and reviver are passed as separate function arguments, not as an options object.

Shows how to create a localStorage engine, integrate it with redux-storage middleware and reducer, and load persisted state on startup.

import { createStore, combineReducers } from 'redux'; import { reducer as storageReducer } from 'redux-storage'; import createEngine from 'redux-storage-engine-localstorage'; import reduxStorageMiddleware from 'redux-storage-middleware'; const engine = createEngine('my-app-key'); const reducer = storageReducer(combineReducers({ /* your reducers */ })); const middleware = reduxStorageMiddleware(engine); const store = createStore(reducer, applyMiddleware(middleware)); // The store is now persisted to localStorage under the key 'my-app-key'. // To load persisted state on startup: import * as storage from 'redux-storage'; storage.load(engine).then((state) => { // state is the loaded object, can be used to rehydrate store });
Debug
Known issues
gotchalocalStorage is synchronous and blocks the JS thread during save/load operations.
fix
For larger state trees, consider using an async storage backend like redux-storage-engine-localforage or switch to redux-persist.
affects: >=1.0.0
deprecatedThe original package by michaelcontento is deprecated; this fork is maintained but in maintenance mode.
fix
Check for updates on GitHub; consider migrating to redux-persist for active development.
affects: >=1.0.0
gotchaInternet Explorer <= 11 does not support Promises natively; this engine returns promises that may require a polyfill.
fix
Include a Promise polyfill (e.g., es6-promise) or use the 'fake-promise' variant.
affects: >=1.0.0
breakingThe engine stores the entire state tree under a single localStorage key; there is no support for separate slices or custom serialization per reducer.
fix
If you need per-reducer persistence, consider redux-persist or custom middleware.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: createEngine is not a function
Using named import { createEngine } instead of default import.
fix
Use default import: import createEngine from 'redux-storage-engine-localstorage'
Uncaught (in promise) TypeError: Cannot read property 'then' of undefined
The engine load method returns a promise but the platform lacks Promise support (e.g., IE11).
fix
Polyfill Promise with a library like es6-promise.
Error: Invalid engine. Must provide object with save and load methods.
Passing wrong argument to redux-storage middleware; the engine object is not correctly created.
fix
Ensure createEngine is called with a string key: const engine = createEngine('my-key');
Upgrade
Version history
1.1.4latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
21 hits · last 30 days
node
18
Amazon
1
Resources
redux-storage-engine-localstorage — npm install redux-storage-engine-localstorage · libregistry