⚠️ Internal package. This is a building block of
rtcforge. Unless you need advanced/custom wiring, installrtcforgeand import fromrtcforge/client,rtcforge/server,rtcforge/media, orrtcforge/filetransferinstead.
WebSocket signaling server for RTCForge — session lifecycle, rooms, auth, and cluster sharding.
The server-side entry point. SignalingServer accepts WebSocket connections, authenticates peers, groups them into Rooms, and relays the signaling messages (offers, answers, ICE candidates) that WebRTC needs to establish peer connections. RoomRouter shards rooms across multiple server nodes.
Every WebRTC app needs a signaling channel before media can flow — peers must exchange connection info through a server. This package gives you that channel with auth hooks, rate-limiting, and heartbeat built in, so you don't hand-roll a WebSocket protocol.
rtcforge-sdk ⇄ rtcforge-signaling (clients connect here to find each other)
└─ RoomRouter → shard across nodes
Backend layer. Pairs with rtcforge-sdk on the client.
SignalingServer — WebSocket lifecycle, auth, heartbeat, rate-limit.Room / Peer — session grouping and per-connection state.RoomRouter — consistent-hash room sharding for multi-node clusters.import { SignalingServer } from "rtcforge-signaling";
const server = new SignalingServer({
port: 3001,
// The auth hook MUST return roomId, peerId, and role (validated by
// AuthPayloadSchema) — returning only { peerId } rejects every connection.
auth: async (token) => {
const user = await verify(token);
return { roomId: user.roomId, peerId: user.id, role: user.role ?? "" };
},
maxPeersPerRoom: 50,
});
await server.start();
Or use the one-call helper, which starts the server with safe defaults on
(rate-limit, payload cap, connection/room caps) and a warn-level logger:
import { createSignalingServer } from "rtcforge-signaling";
const server = await createSignalingServer({ port: 3001, auth });
Part of RTCForge. See docs/PUBLISHING.md.