{"id":13482964,"url":"https://github.com/mappum/electron-webrtc","last_synced_at":"2026-04-02T02:37:08.423Z","repository":{"id":57111028,"uuid":"49934899","full_name":"mappum/electron-webrtc","owner":"mappum","description":"⚛ Use WebRTC in Node.js via a hidden Electron process","archived":false,"fork":false,"pushed_at":"2018-02-20T04:43:35.000Z","size":65,"stargazers_count":318,"open_issues_count":15,"forks_count":41,"subscribers_count":16,"default_branch":"master","last_synced_at":"2025-08-08T15:50:12.834Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mappum.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-01-19T07:32:12.000Z","updated_at":"2025-01-18T05:47:19.000Z","dependencies_parsed_at":"2022-08-20T20:20:53.082Z","dependency_job_id":null,"html_url":"https://github.com/mappum/electron-webrtc","commit_stats":null,"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"purl":"pkg:github/mappum/electron-webrtc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mappum%2Felectron-webrtc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mappum%2Felectron-webrtc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mappum%2Felectron-webrtc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mappum%2Felectron-webrtc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mappum","download_url":"https://codeload.github.com/mappum/electron-webrtc/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mappum%2Felectron-webrtc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271104893,"owners_count":24700015,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-19T02:00:09.176Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T17:01:07.080Z","updated_at":"2026-04-02T02:37:08.383Z","avatar_url":"https://github.com/mappum.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","Modules"],"sub_categories":[],"readme":"# electron-webrtc\n\n[![npm version](https://img.shields.io/npm/v/electron-webrtc.svg)](https://www.npmjs.com/package/electron-webrtc)\n[![Build Status](https://travis-ci.org/mappum/electron-webrtc.svg?branch=master)](https://travis-ci.org/mappum/electron-webrtc)\n[![Dependency Status](https://david-dm.org/mappum/electron-webrtc.svg)](https://david-dm.org/mappum/electron-webrtc)\n\nUse WebRTC in Node.js via a hidden Electron process\n\nWebRTC is a powerful web API that lets browsers make peer-to-peer connections, and has already been\ndeployed in [many popular browsers](http://caniuse.com/#feat=rtcpeerconnection). It may sometimes be\nuseful to let Node.js programs use WebRTC, e.g. in [`webtorrent-hybrid`](https://github.com/feross/webtorrent-hybrid). However, the modules for WebRTC in Node ([`node-webrtc`](https://github.com/js-platform/node-webrtc) and [`node-rtc-peer-connection`](https://github.com/nickdesaulniers/node-rtc-peer-connection)) are either hard to install, broken, or incomplete.\n\nAs a hack, this module talks to an invisible Electron instance in the background (using [`electron-eval`](https://github.com/mappum/electron-eval)) to use Chromium's built-in WebRTC implementation.\n\n## Status\n\nThis module is compatible with [`simple-peer`](https://github.com/feross/simple-peer) and passes its tests.\n\n`electron-webrtc` is intended for use with RTCDataChannels, so the MediaStream API is not supported.\n\n## Usage\n\n`npm install electron-webrtc`\n\n```js\n// call exported function to create Electron process\nvar wrtc = require('electron-webrtc')()\n\n// handle errors that may occur when trying to communicate with Electron\nwrtc.on('error', function (err) { console.log(err) })\n\n// uses the same API as the `wrtc` package\nvar pc = new wrtc.RTCPeerConnection(config)\n\n// compatible with `simple-peer`\nvar peer = new SimplePeer({\n  initiator: true,\n  wrtc: wrtc\n})\n\n// listen for errors\nwrtc.on('error', function (err, source) {\n  console.error(err)\n})\n```\n\n### Methods\n\n#### `var wrtc = require('electron-webrtc')([opts])`\n\nCalling the function exported by this module will create a new hidden Electron process. It is recommended to only create one, since Electron uses a lot of resources.\n\nAn optional `opts` object may contain specific options (including headless mode). See [`electron-eval`](https://github.com/mappum/electron-eval#var-daemon--electronevalopts)\n\nThe object returned by this function has the same API as the [`node-webrtc`](https://github.com/js-platform/node-webrtc) package.\n\nAny errors that occur when communicating with the Electron daemon will be emitted by the `wrtc` object (`wrtc.on('error', ...)`).\n\n#### `wrtc.close()`\n\nCloses the Electron process and releases its resources. You may not need to do this since the Electron process will close automatically after the Node process terminates.\n\n### Properties\n\n#### `wrtc.electronDaemon`\n\nA handle to the [`electron-eval`](https://github.com/mappum/electron-eval) daemon that this module uses to talk to the Electron process.\n\n### Events\n\n#### - `error`\nEmitted by `RTCPeerConnection` or `RTCDataChannel` when `daemon.eval()` evaluates code that throws an internal error.\n\n### Running on a headless server\n\nChromium normally won't run on a headless server since it expects a screen that it can render to. So to work around this, we can use `Xvfb`, a utility that creates a framebuffer that Chromium can use as a virtual screen.\n\nFirst, install `Xvfb`:\n```sh\napt-get install xvfb # Ubuntu/Debian\nyum install xorg-x11-server-Xvfb # CentOS\n```\n\nCreate the `HEADLESS` env variable:\n```sh\nexport HEADLESS=true\n```\n\nOr if you want to do it programmatically, initialize a new instance and pass in `headless` as a key as demonstrated:\n```js\nvar wrtc = require('electron-webrtc')({ headless: true })\n```\n\nNow you may run your WebRTC code with `electron-webrtc` :)\n\n## Related Modules\n\n- [`node-webrtc`](https://github.com/js-platform/node-webrtc)\n- [`node-rtc-peer-connection`](https://github.com/nickdesaulniers/node-rtc-peer-connection)\n- [`electron-eval`](https://github.com/mappum/electron-eval)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmappum%2Felectron-webrtc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmappum%2Felectron-webrtc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmappum%2Felectron-webrtc/lists"}