Get unlimited public & private packages + team-based management with npm Teams.Learn more »

@piotr-cz/redux-persist-idb-storage

1.0.2 • Public • Published

Redux Persist adapter for IndexedDB storage

Storage adapter to use IndexedDB via idb v3 with redux-persist ripped from idb v3 docs > Examples section

Installation

npm install --save @piotr-cz/redux-persist-idb-storage

or

yarn add @piotr-cz/redux-persist-idb-storage

Requirements

Setup

Import the storage and include it in persistConfig when creating Redux store:

// configureStore.js
 
// Using CommonJS modules
import createIdbStorage from '@piotr-cz/redux-persist-idb-storage'
 
// Or using ES6 modules
import createIdbStorage from '@piotr-cz/redux-persist-idb-storage/src'
 
const persistConfig = {
  key: 'root',
  storage: createIdbStorage({name: 'myApp', storeName: 'keyval'}),
  serialize: false, // Data serialization is not required and disabling it allows you to inspect storage value in DevTools
}
 
// ...

Options

See idb API

  • {string} name - Defaults to keyval-store
  • {string} storeName - Defaults to keyval
  • {number} version - Defaults to 1
  • {function} upgradeCallback - Defaults to upgradeDb => upgradeDb.createObjectStore(options.storeName)

Notes

  • idb dependency is locked to version ^3.0.0 as 4+ uses proxies which are not supported in older browsers
  • credits go to idb authors

Install

npm i @piotr-cz/redux-persist-idb-storage

DownloadsWeekly Downloads

955

Version

1.0.2

License

MIT

Unpacked Size

17.8 kB

Total Files

10

Last publish

Collaborators

  • avatar