Five-minute quickstart
Requirements: IOSignal JS 7.2.0, Node.js 22.16.0 or later, npm, and three terminals.
Success: the receiver prints hello#message and Hello, IOSignal!.
Prefer a complete web app? Start with runnable examples or choose a path.
1. Prepare a project
mkdir iosignal-hello
cd iosignal-hello
npm init -y
npm install --save-exact iosignal@7.2.0
The .mjs extension enables ES modules without changing package.json.
2. Start the server
Save as server.mjs:
import { Server } from 'iosignal';
const server = new Server({ port: 7777 });
server.on('ready', () => console.log('Server ready: ws://localhost:7777'));
In terminal 1, run node server.mjs and leave it running.
3. Start the receiver
Save as receiver.mjs:
import { IO } from 'iosignal';
const io = new IO('ws://localhost:7777');
io.listen('hello#message', (tag, message) => {
console.log(tag, message);
});
io.on('ready', () => console.log('Receiver ready:', io.cid));
io.on('error', console.error);
In terminal 2, run node receiver.mjs and wait for Receiver ready. listen() registers the handler and schedules the subscription when the connection becomes ready.
4. Send a message
Save as sender.mjs:
import { IO } from 'iosignal';
const io = new IO('ws://localhost:7777');
io.on('ready', () => {
io.signal('hello#message', 'Hello, IOSignal!');
console.log('Message sent');
});
io.on('error', console.error);
In terminal 3, run node sender.mjs. The receiver should print hello#message Hello, IOSignal!. Here hello is the channel and message is the topic. Stop each process with Ctrl+C.
Next steps
- Signal tags: channels, direct messages, and CID publishing.
- Runnable web examples: exchange messages in two browser tabs.
- Client API: methods, events, and limits.
- Troubleshooting: diagnose setup, connection, and delivery failures.