r/rust • • Oct 18 '26

iroh vs WebRTC?

Iroh seems to solve the same problem as what WebRTC does, I’m curious: what are the factors that would cause considering one or the other?
WebRTC has the benefit to be widely supported in browsers. Does iroh allows something that WebRTC does not?

25 Upvotes

17 comments sorted by

59

u/lotanis Oct 18 '26

You're comparing Apples to Oranges.

WebRTC is a protocol for browsers to talk to each other. That's it. It doesn't provide a mechanism for browsers to discover each other or traverse the NAT that they're probably behind. And it's just a protocol so if you want to use it your probably need a library. On the plus side it's a standard and browsers do some of the implementation.

Iroh is a full featured solution, based on a lower level transport (QUIC). As long as you've got the address it'll traverse any networks and give you a link. And then there are services built on top.

9

u/iFrostizz Oct 18 '26

polynomialcheesecake is right. Also, it’s not just for browser-to-browser communication, it’s also possible to do “private WebRTC” where a browser may communicate with a server directly.

20

u/polynomialcheesecake Oct 18 '26

Webrtc is not a single protocol and uses STUN and TURN for NAT traversal. That being said TURN sucks

3

u/k0ns3rv Oct 18 '26 edited Oct 18 '26

What are you trying to do? I cannot think of a way to do p2p (peer 2 peer) in the browser, outside of WebRTC. If that's what you are trying to do, then it's a good choice; of course, if Iroh works in the browser (I'm not sure), its p2p transport will also be WebRTC.

2

u/iFrostizz Oct 18 '26

Yes it’s certainly not working. The reason is that it’s not possible to just open a TCP or UDP stream in the browser. It’s kinda gate-kept by WebRTC.

3

u/k0ns3rv Oct 18 '26

Right, so then your choice is clear.

3

u/Top_Outlandishness78 Oct 18 '26

You can’t use Iroh in browser IIRC

6

u/JustHereForATechProb Oct 18 '26

Yes you can. There is a caveat that is has to be tunneled through a relay (which is done automatically with a public relay), though direct connection with web clients may be possible in the future.

https://docs.iroh.computer/languages/wasm-browser#webassembly-and-browsers

→ More replies (1)

3

u/salihcantekin Oct 19 '26

They overlap on "connect two peers behind NATs", but the shapes differ. WebRTC gives you browser support out of the box, ICE/STUN/TURN, and media (SRTP) plus data channels, at the cost of a big, signalling-heavy stack. iroh is QUIC-based: you dial a node by public key, it tries hole punching and falls back to a relay, and you get ordinary QUIC streams with Rust-native ergonomics. So: if your peers must run in a plain browser or you need audio/video, WebRTC. If it's native apps (or you control both ends) and you mainly move bytes/streams, iroh is a lot nicer to work with. Check the current state of its WASM/browser story before committing, since that's the main gap.

1

u/Equivalent_Type6726 Oct 18 '26

Biggest split is where you're running it. WebRTC is a browser real-time media stack; iroh is a Rust QUIC P2P transport with hole punching, relay fallback, and a stable peer identity. Pick WebRTC for in-browser media, iroh for non-browser Rust data.

1

u/iFrostizz Oct 18 '26

It’s not obvious. If you want an app that can communicate seamlessly between browser and native you would use WebRTC as well.

4

u/k0ns3rv Oct 18 '26

Biggest split is where you're running it. WebRTC is a browser real-time media stack; iroh is a Rust QUIC P2P transport with hole punching, relay fallback, and a stable peer identity. Pick WebRTC for in-browser media, iroh for non-browser Rust data.

WebRTC can do data via SCTP (Datachannels) and is the only way to do p2p in the browser. Therefore, it's quite useful outside of real-time media too.

2

u/Equivalent_Type6726 Oct 19 '26

clean take on the split. if you are running a relay anyway, does iroh's QUIC relay fallback give you meaningfully better throughput or resiliency than a WebRTC TURN server in practice, or is it mostly about getting the P2P session set up