Use the browser module with a bundler
Baseline: IOSignal JS 7.2.0. Start the quickstart server first.
npm install --save-exact iosignal@7.2.0
import IO from 'iosignal/browser/esm/io.js';
const io = new IO('ws://localhost:7777');
io.on('room#chat', (tag, message) => console.log(tag, message));
io.on('ready', () => {
io.subscribe('room#chat');
io.signal('room#chat', 'Hello from the browser');
});
The browser module is a default export. iosignal/io.js is another supported browser ESM entry point. Do not use the Node.js named import in a browser bundle.
This example sends the subscription before the first message, so it also receives its own message. Register handlers once; subscribe on every ready to handle reconnection. See subscriptions and lifecycle.
If a component exclusively owns the IO instance, call destroy() when it is removed. For a shared instance, remove only that component's handlers. See client API and runnable framework examples.