# webrtc-polyfill

> High performance WebRTC polyfill for Node.JS via libdatachannel using Node Native/NAPI.

Latest version **1.2.2** (published 2026-06-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install webrtc-polyfill
pnpm add webrtc-polyfill
yarn add webrtc-polyfill
bun add webrtc-polyfill
```

## Health

**Score 60/100 (C)** — status: active.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.2.2 |
| Published | 2026-06-08 |
| First published | 2023-08-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=16.0.0 |
| Dependencies | 1 |
| Unpacked size | 56.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | ThaUnknown |
| Maintainers | thaunknown |
| Keywords | webrtc, w3c, nodejs, polyfill, p2p, peer, libdatachannel, peer-to-peer, datachannel, data channel |

## Links

- npm: https://www.npmjs.com/package/webrtc-polyfill
- Repository: https://github.com/ThaUnknown/webrtc-polyfill.git
- Homepage: https://github.com/ThaUnknown/webrtc-polyfill#readme
- Issues: https://github.com/ThaUnknown/webrtc-polyfill/issues
- npm.io page: https://npm.io/package/webrtc-polyfill

## Dependencies (1)

- [node-datachannel](https://npm.io/package/node-datachannel.md) ^0.32.3

## Recent versions

- 1.2.2 (latest) — 2026-06-08
- 1.2.1 — 2026-05-21
- 1.2.0 — 2026-01-15
- 1.1.11 — 2026-01-15
- 1.1.10 — 2024-11-05
- 1.1.9 — 2024-11-05
- 1.1.8 — 2024-07-17
- 1.1.7 — 2024-07-11
- 1.1.6 — 2024-05-23
- 1.1.5 — 2024-05-22
- 1.1.4 — 2024-05-22
- 1.1.3 — 2024-05-14
- 1.1.2 — 2024-05-14
- 1.1.1 — 2024-04-22
- 1.1.0 — 2024-04-22
- … 14 more at https://npm.io/package/webrtc-polyfill/versions

## README

<h1 align="center">
  <img height="120px" src="https://upload.wikimedia.org/wikipedia/commons/d/d9/Node.js_logo.svg" />&nbsp;&nbsp;&nbsp;&nbsp;
  <img height="120px" src="https://webrtc.github.io/webrtc-org/assets/images/webrtc-logo-vert-retro-dist.svg" />
</h1>

webrtc-polyfill is a Node.js Native Addon that provides bindings to [libdatachannel](https://github.com/paullouisageneau/libdatachannel). This project aims for spec-compliance and is tested using the W3C's [web-platform-tests](https://github.com/web-platform-tests/wpt) project, but doesn't pass all of its tests, instead focuses on the important ones, like close, error and data events, states, while offering performance better than any alternative. A number of [nonstandard APIs](docs/nonstandard-apis.md) for testing are also included.

Notably most of the core WebRTC functionality is async in contrast to how web handles it. Notable examples are:
```js
datachannel.send(new Blob([new Uint8Array([1,2,3,4])]))
datachannel.send(new Uint8Array([1,2,3,4])) // this will arrive before the blob, as blob internals are asynchronous
```
and
```js
datachannel.send(new Uint8Array([1,2,3,4]))
datachannel.bufferedAmount // not always 4, as the thread that runs it is async and might flush instantly!
```

Install
-------

```
pnpm install webrtc-polyfill
```
Supported Platforms
-------------------

For supported platforms see the [node-channel bindings compatibility table](https://github.com/murat-dogan/node-datachannel/#supported-platforms). Note that node versions under 14 require a global EventTarget and Event polyfill.

Testing
-------
Requirements: Python, Node.js

---
_Source: https://npm.io/package/webrtc-polyfill · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
