WebRTC data channels for Node.js, backed by libdatachannel and validated with 620 selected Web Platform Tests subtests.
npm install @mertushka/webrtc-nodeconst { RTCPeerConnection } = require("@mertushka/webrtc-node");
const pc = new RTCPeerConnection({ iceServers: [] });
const channel = pc.createDataChannel("events");
channel.addEventListener("open", () => {
channel.send("hello from Node");
});
channel.addEventListener("message", (event) => {
console.log(event.data);
});See examples/datachannel.js for a complete local offer/answer exchange.
Node.js 20 or newer is required. The npm package downloads a matching Node-API
prebuild when available, verifies its SHA-256 digest and target, then falls back
to a cmake-js source build.
| OS | Prebuild targets | Node 20 | Node 22 | Node 24 |
|---|---|---|---|---|
| Linux | x64 glibc, x64 musl | ✅ | ✅ | ✅ |
| macOS | x64, arm64 | ✅ | ✅ | ✅ |
| Windows | x64, arm64 | ✅ | ✅ | ✅ |
Source builds require CMake, a C++17 compiler, and OpenSSL development libraries.
Local benchmark snapshots show this package ahead on binary throughput and object operation rates. Benchmarks are environment-sensitive; treat them as directional rather than a substitute for testing your workload.
| Metric | webrtc-node |
node-datachannel |
@roamhq/wrtc |
|---|---|---|---|
| Linux binary 8 KiB x1000 | 39.9 MB/s | 30.4 MB/s | 27.4 MB/s |
| Linux construct+close PC | 53k ops/s | 3.2k ops/s | 200 ops/s |
| Linux negotiated DC create+close | 2.2k ops/s | 974 ops/s | 173 ops/s |
Read CONTRIBUTING.md before opening a pull request. Public API changes should update runtime code, TypeScript declarations, tests, and WPT documentation together.
Mozilla Public License 2.0. See LICENSE.