WebSocket messages to Redux action bridge that lifts WebSocket messages into Redux actions and vice versa. Version 0.3.0-0 (pre-release). It automatically parses JSON messages that follow Flux Standard Action (FSA) format and dispatches them to the store, and allows sending Redux actions as WebSocket messages. Supports raw messages and FSA-style actions, with lifecycle events for open, close, and message. Lightweight middleware with namespace support for multiple connections. Inspired by redux-websocket but simpler to integrate.
npm install redux-websocket-bridgeNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to configure the middleware with a WebSocket URL, handle incoming FSA messages in a reducer, and dispatch actions to send messages over WebSocket.
Ensure server sends { type: 'ACTION_TYPE', payload: ... } as JSON string.Call the function with URL: ReduxWebSocketBridge('ws://...') instead of passing class/function directly.Pin to exact version if stability needed, or wait for stable release.
Always import SEND and use with template literal: type: `@@websocket/${SEND}`Check action.type for '@@websocket/OPEN' et al. for connection state; handle custom types for messages.
Use named import or call factory: import createBridge from 'redux-websocket-bridge'; const middleware = createBridge('ws://...');Ensure dispatch uses plain object with type: `@@websocket/${SEND}` and payload as string or JSON.Verify WebSocket URL and server availability; consider using try-catch or reconnection logic.
Check server sends valid JSON with 'type' property; handle raw messages in @@websocket/MESSAGE reducer.