Skip to content

robinmalburn/redux-persist-chrome-storage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

11aee79 · Jun 23, 2024

History

33 Commits
Dec 27, 2021
Nov 26, 2021
Aug 16, 2021
Aug 16, 2021
Feb 23, 2018
Aug 16, 2021
Feb 23, 2018
Aug 16, 2021
Dec 27, 2021
Jun 23, 2024
Jun 23, 2024

Repository files navigation

Redux Persist Chrome Storage

Tests

Storage adaptor for using Google Chrome's Storage API with redux-persist.

The main use case for this adaptor is when writing Chrome extensions and making use of either the Sync, Local or Managed StorageArea drivers to persist your redux state.

Installation

npm: npm install redux-persist-chrome-storage

yarn: yarn add redux-persist-chrome-storage

Usage

import { createStore } from 'redux'
import { persistStore, persistReducer } from 'redux-persist'
import createChromeStorage from 'redux-persist-chrome-storage'
import reducer from './reducers'

// Create a ChromeStorage instance using the chrome runtime and the Sync StorageArea.
const storage = createChromeStorage(window.chrome, 'sync');

const config = {
  key: 'root',
  storage,
};

const persistedReducer = persistReducer(config, reducer);

export default () => {
  let store = createStore(persistedReducer)
  let persistor = persistStore(store)
  return { store, persistor };
}

About

redux-persist storage adaptor for Chrome extensions storage API.

Resources

License

Stars

Watchers

Forks

Packages

No packages published