redux-persist-webextension-storage
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/redux-persist-webextension-storage package

1.0.2 • Public • Published

redux-persist-webextension-storage

A WebExtension Storage storage engine for redux-persist.

Installation

Add the redux-persist-webextension-storage NPM package via NPM or Yarn:

$ yarn add redux-persist-webextension-storage

Usage

There are separate storage engines for local storage and sync storage. Import the one you need, or both, and pass them as storage engines when configuring your store.

// configureStore.js
 
import { combineReducers, createStore } from 'redux'
import { persistStore, persistReducer } from 'redux-persist'
import { localStorage, syncStorage } from 'redux-persist-webextension-storage'
 
import localStorageReducer from './localStorageReducer';
import syncStorageReducer from './syncStorageReducer';
 
const localStorageConfig = {
  key: 'localStorage',
  storage: syncStorage,
}
 
const syncStorageConfig = {
  key: 'syncStorage',
  storage: syncStorage,
}
 
// Persist each of the storage areas under different keys and with different storage engines.
const rootReducer = combineReducers({
  localStorage: persistReducer(localStorageConfig, localStorageReducer),
  syncStorage: persistReducer(syncStorageConfig, syncStorageReducer),
})
 
export default () => {
  const store = createStore(rootReducer)
  const persistor = persistStore(store)
  return { store, persistor }
}

Readme

Keywords

Package Sidebar

Install

npm i redux-persist-webextension-storage

Weekly Downloads

1,916

Version

1.0.2

License

MIT

Unpacked Size

60.1 kB

Total Files

12

Last publish

Collaborators

  • ssorallen