Registry / realtime / redux-cluster-ws

redux-cluster-ws

JSON →
library2.0.116jsnpmunverified

WebSocket wrapper for redux-cluster enabling real-time Redux store synchronization across Node.js servers and clients (including browser) using native WebSocket, not Socket.IO. Current version 2.0.116, actively maintained. Key differentiators: lightweight native WS protocol, built-in authentication (login/password), IP banning/connection limits, dual ESM/CJS packaging. Requires ws@^8.19.0 as peer dependency. Full TypeScript support since v2.0.

npm install redux-cluster-ws
INSTALL
IMPORT
SIG · REDUX-CLUSTER-WS
R
redux-cluster-ws
realtimejavascriptv2.0.116
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.

createWSServer
import { createWSServer } from 'redux-cluster-ws'
const createWSServer = require('redux-cluster-ws')
Default export or named? README shows named import. v2 has named exports only.
createWSClient
import { createWSClient } from 'redux-cluster-ws'
import reduxClusterWs from 'redux-cluster-ws'
v2 removed default export; use named imports.
ReduxCluster
import { ReduxCluster } from 'redux-cluster'
import { ReduxCluster } from 'redux-cluster-ws'
ReduxCluster is from 'redux-cluster' package, NOT from redux-cluster-ws.

Sets up a WebSocket server and client using redux-cluster-ws with a simple counter reducer, demonstrates real-time state sync.

import { createWSServer } from 'redux-cluster-ws'; import { createWSClient } from 'redux-cluster-ws'; import { ReduxCluster } from 'redux-cluster'; function counterReducer(state = { count: 0 }, action) { switch (action.type) { case 'INCREMENT': return { count: state.count + 1 }; case 'DECREMENT': return { count: state.count - 1 }; default: return state; } } // Server const serverStore = new ReduxCluster(counterReducer); serverStore.createWSServer({ port: 8080, logins: { admin: 'password123' } }); // Client (Node.js) const clientStore = new ReduxCluster(counterReducer); clientStore.createWSClient({ host: 'ws://localhost', port: 8080, login: 'admin', password: process.env.PASSWORD ?? 'password123' }); clientStore.subscribe(() => console.log('State:', clientStore.getState())); clientStore.dispatch({ type: 'INCREMENT' });
Debug
Known issues
breakingv2.0 removed Socket.IO support completely. All connections now use native WebSocket only.
fix
Update server and client to use WebSocket URLs (ws:// instead of http://). Replace Socket.IO options with WebSocket config.
affects: >=2.0.0
gotchaReduxCluster import comes from 'redux-cluster' package, not from 'redux-cluster-ws'. Common mistake to import from wrong package.
fix
Install and import from 'redux-cluster' for the store class, and only import createWSServer/createWSClient from 'redux-cluster-ws'.
affects: >=1.0.0
breakingv2.0 requires peer dependency ws@^8.19.0. Older Node.js versions (<16) are not supported.
fix
Update Node.js to v16+ and ensure ws@^8.19.0 is installed.
affects: >=2.0.0
deprecatedDefault export deprecated in v2. Import via named imports only.
fix
Use import { createWSServer, createWSClient } from 'redux-cluster-ws' instead of import reduxClusterWs from 'redux-cluster-ws'.
affects: >=2.0.0
Errors
Common errors & fixes
Error: Cannot find module 'ws'
Missing peer dependency 'ws' which is required for WebSocket functionality.
fix
npm install ws@^8.19.0
TypeError: redux_cluster_ws_1.default is not a function
Using default import in v2 which removed default export and only provides named exports.
fix
Change to: import { createWSServer, createWSClient } from 'redux-cluster-ws'
Error: ReduxCluster is not a constructor
Importing ReduxCluster from 'redux-cluster-ws' instead of 'redux-cluster'.
fix
Use: import { ReduxCluster } from 'redux-cluster'
Upgrade
Version history
2.0.116latest on npm
Audit
Dependencies
wsrequiredWebSocket server and client implementation in Node.js
redux-clusterrequiredCore Redux cluster store for state synchronization
reduxrequiredRedux core for reducer pattern (listed as separate install in README but ultimately required)
Agent activity
37 hits · last 30 days
node
34
OpenAI (training)
1
Resources
redux-cluster-ws — npm install redux-cluster-ws · libregistry