An open API service indexing awesome lists of open source software.

https://github.com/mertushka/webrtc-node

WebRTC data channels for Node.js, backed by libdatachannel and validated with 620 selected Web Platform Tests subtests
https://github.com/mertushka/webrtc-node

libdatachannel node-api nodejs rtcdatachannel rtcpeerconnection webrtc wpt

Last synced: about 1 month ago
JSON representation

WebRTC data channels for Node.js, backed by libdatachannel and validated with 620 selected Web Platform Tests subtests

Awesome Lists containing this project

README

          

webrtc-node


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


WebRTC data channels for Node.js, backed by
libdatachannel
and validated with 620 selected Web Platform Tests subtests.

```sh
npm install @mertushka/webrtc-node
```

## Usage

```js
const { 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](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 | ✅ | ✅ | ✅ |
| macOS | x64, arm64 | ✅ | ✅ | ✅ |
| Windows | x64, arm64 | ✅ | ✅ | ✅ |

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

## Performance Snapshot

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 |

## Contributing

Read [CONTRIBUTING.md](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](LICENSE).