Skip to content

Latest commit

 

History

History
87 lines (66 loc) · 3.12 KB

README.md

File metadata and controls

87 lines (66 loc) · 3.12 KB

@webrtc-node/webrtc

CI npm Node.js API Data Channels TypeScript WPT Native API License

Data-channel-first WebRTC for Node.js with browser-shaped RTCPeerConnection and RTCDataChannel APIs.

Backed by libdatachannel, shipped as a Node-API native addon, and validated with 620 selected Web Platform Tests subtests.

npm install @webrtc-node/webrtc

Usage

const { RTCPeerConnection } = require("@webrtc-node/webrtc");

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.

Supported Platforms

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, arm64 glibc ✅ ✅ ✅
macOS x64, arm64 ✅ ✅ ✅
Windows x64, arm64 ✅ ✅ ✅

Source builds require CMake, a C++17 compiler, and OpenSSL development libraries.

Performance Snapshot

Local benchmark snapshots show the package ahead on binary throughput and object operation rates for data-channel workloads. Benchmarks are environment-sensitive; treat them as directional rather than a substitute for testing your workload.

Metric @webrtc-node/webrtc 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

Contributing

Read CONTRIBUTING.md before opening a pull request. Public API changes should update runtime code, TypeScript declarations, tests, and WPT documentation together.

License

Mozilla Public License 2.0. See LICENSE.