Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
createStateSyncMiddleware
✓ import { createStateSyncMiddleware, initMessageListener, initStateWithPrevTab, withReduxStateSync } from 'redux-state-sync';
✗ const createStateSyncMiddleware = require('redux-state-sync').createStateSyncMiddleware;
Package provides named exports only. CommonJS require is possible but TypeScript types require ESM import.
initMessageListener
✓ import { initMessageListener } from 'redux-state-sync';
✗ import initMessageListener from 'redux-state-sync';
Default import does not work; must use named import.
withReduxStateSync
✓ import { withReduxStateSync } from 'redux-state-sync';
✗ const withReduxStateSync = require('redux-state-sync').withReduxStateSync;
Used to wrap root reducer for state rehydration from other tabs.
Shows full setup: create middleware, wrap reducer, init state from previous tab, and blacklist an action type.
import { createStore, applyMiddleware, combineReducers } from 'redux';
import { createStateSyncMiddleware, initStateWithPrevTab, withReduxStateSync } from 'redux-state-sync';
const config = { blacklist: ['TOGGLE_TODO'] };
const middlewares = [createStateSyncMiddleware(config)];
const rootReducer = combineReducers({
todos: (state = [], action) => state,
visibilityFilter: (state = 'SHOW_ALL', action) => state
});
const store = createStore(
withReduxStateSync(rootReducer),
applyMiddleware(...middlewares)
);
initStateWithPrevTab(store);
// Now dispatch actions normally; other tabs will sync automatically
Errors
Common errors & fixes
Error: Actions must be plain objects. Use custom middleware for async actions.
An action with a function payload is dispatched, which violates serialization requirement.
fixRemove functions from action payloads or serialize them before dispatch.
TypeError: store.dispatch is not a function
initMessageListener or initStateWithPrevTab is called before the store is fully created or passed incorrectly.
fixEnsure store is passed directly: initStateWithPrevTab(store); do not wrap store in another function.
Module not found: Can't resolve 'redux-state-sync'
Package not installed; or using bundler with incorrect module resolution.
fixRun npm install redux-state-sync and ensure node_modules is present.
Audit
Dependencies
reduxrequiredPeer dependency required for middleware integration with Redux store.
broadcast-channelrequiredUsed as a fallback for BroadcastChannel API in unsupported browsers.