A JavaScript/TypeScript SDK for WebSocket communication on the Internet Computer (IC) blockchain. Version 0.5.0, actively developed. Enables real-time, bidirectional messaging between dapps and canisters via IC WebSocket gateways. Differentiates from standard WebSocket by integrating with IC authentication and agent-based calls. Requires @dfinity/agent, @dfinity/candid, @dfinity/identity-secp256k1, and @dfinity/principal as peer dependencies. Ships TypeScript types.
npm install ic-websocket-jsNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates an IC WebSocket connection using a generated identity and agent, listens for events, and sends a message.
Install @dfinity/agent, @dfinity/candid, @dfinity/identity-secp256k1, @dfinity/principal as peers.
Ensure gatewayUrl is correct and the gateway is running.
Use the new object-based configuration: { canisterId, agent, gatewayUrl }. Previous versions may have used positional arguments.Add event listeners before calling connect() to avoid missing events.
npm install @dfinity/agent @dfinity/candid @dfinity/identity-secp256k1 @dfinity/principal
Use 'new IcWebSocket(...)'
Call send() only after the 'open' event fires.