Registry / storage / redux-persist-chrome-storage

redux-persist-chrome-storage

JSON →
library2.1.9jsnpmunverified

Storage adaptor for using Google Chrome's Storage API with redux-persist, version 2.1.9. Enables persisting Redux state in Chrome extensions using sync, local, or managed storage. Released in 2024, it is a focused utility with peer dependency on redux-persist >=5.0. Requires Node.js >=22. Key differentiator: specifically designed for Chrome extension environments, wrapping the chrome.storage API to integrate seamlessly with redux-persist's persistence workflow.

npm install redux-persist-chrome-storage
INSTALL
IMPORT
SIG · REDUX-PERSIST-CHRO
R
redux-persist-chrome-storage
storagejavascriptv2.1.9
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.

createChromeStorage
import createChromeStorage from 'redux-persist-chrome-storage'
const createChromeStorage = require('redux-persist-chrome-storage')
Default export; package is ESM-only, uses named export pattern as default.
ChromeStorageConfig
import type { ChromeStorageConfig } from 'redux-persist-chrome-storage'
TypeScript type for the config object passed to createChromeStorage; only available in ESM.
ChromeStorage
import type { ChromeStorage } from 'redux-persist-chrome-storage'
TypeScript type for the storage object returned; import as type to avoid runtime errors.

Setup redux-persist with Chrome sync storage in a Chrome extension. Shows creation of storage adaptor, persist config, and store creation.

import { createStore } from 'redux'; import { persistStore, persistReducer } from 'redux-persist'; import createChromeStorage from 'redux-persist-chrome-storage'; import reducer from './reducers'; 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 }; };
Debug
Known issues
gotchaRequires window.chrome to be available. In newer manifest v3 extensions, chrome is available globally but not as window.chrome in service workers.
fix
Use chrome.storage directly in service workers: import { chrome } from 'webextension-polyfill' or use chrome.runtime.getBackgroundPage() in popup scripts.
affects: >=2.0.0
breakingVersion 2.x changed the import path from older 1.x versions. Previously default import from 'redux-persist-chrome-storage' was the only way, but now TypeScript types are available.
fix
No migration needed if using default import; check TypeScript type imports.
affects: >=2.0.0 <2.0.0
deprecatedThe package does not officially support non-Chrome browsers. Using it in Firefox or Edge with chrome-compatible APIs may work but is not tested.
fix
Test thoroughly in target browsers or consider browser-agnostic alternatives like localForage.
affects: *
gotchaStorage area must be one of 'sync', 'local', or 'managed'. Passing an invalid string will throw at runtime.
fix
Always use one of these three strings; check chrome.storage documentation for capacity limits.
affects: *
Errors
Common errors & fixes
TypeError: window.chrome is undefined
Running in a browser without Chrome extension API (e.g., regular web page or Firefox without polyfill).
fix
Ensure code runs only in Chrome extension context; use webextension-polyfill for cross-browser support.
Module not found: Can't resolve 'redux-persist-chrome-storage'
Missing installation or incorrect import path.
fix
Run npm install redux-persist-chrome-storage or yarn add redux-persist-chrome-storage.
TypeError: Cannot destructure property 'setItem' of (intermediate value) as it is undefined.
createChromeStorage was called without the chrome runtime object or invalid storage area.
fix
Ensure first argument is window.chrome (or chrome in background scripts) and second is 'sync', 'local', or 'managed'.
Upgrade
Version history
2.1.9latest on npm
Audit
Dependencies
redux-persistrequiredPeer dependency required for storage adaptor integration
Agent activity
30 hits · last 30 days
node
26
Amazon
1
Resources
redux-persist-chrome-storage — npm install redux-persist-chrome-storage · libregistry