Proper way to integrate WebRTC to Electron app?


I’m trying to develop a peer-to-peer desktop app with Electron and WebRTC which transfers only JSON data betwen peers. I ran into many libraries such as PeerJs, node-crt and electron-webrtc but I’m not sure what’s the best way to properly integrate that, any ideas? thanks


same question.
Who can show us a best-practice?


The WebTorrent desktop app built on Electron and WebRTC might be one place to start looking.


To get started using WebRTC in Electron, you don’t need to do much.

WebRTC is built into Chromium, so Electron has WebRTC automatically in all renderer processes. You can just start writing code that uses the WebRTC APIs (RTCPeerConnection, etc.)

I gave a talk about how we used Electron to build WebTorrent Desktop (, a WebRTC-powered torrent app that can connect to WebRTC browsers!

You can watch my talk from the Signal Conference

All the code for WebTorrent Desktop is open source on GitHub if you want to see how to use it.

If you’re looking for a library to make WebRTC easier to use, you can use any of the libraries that work in the browser: simple-peer, peerjs, etc., etc. I prefer simple-peer which is the one that I wrote for use in WebTorrent.


@feross Can confirm WebRTC works in Electron, however it considers custom protocols to be insecure, like my-app://home, and so navigator.mediaDevices.getUserMedia fails. It works over the file protocol though. Do you know if there’s a workaround for this? I’ve tried passing webPreferences: { webSecurity: false } to BrowserWindow to no avail, and wouldn’t be ideal anyway.


Ah I can answer my own question! Other visitors may find this useful:

Electron allows you to make a custom protocol secure like this:

protocol.registerStandardSchemes(['my-app'], { secure: true });


Can we block webrtc in electron
If yes then how.
Issue is webrtc is leaking my original IP even though I am in proxy


Hi Sir,
I am using WebRTC in Electron JS but onopen event is not working please let me know if you have any solution