The webrtc crate is a thin async layer over a Sans-I/O core
Project brief: Async-friendly WebRTC implementation in Rust. The async webrtc crate is a clean, ergonomic, runtime-agnostic rewrite on top of a Sans-I/O core; it ships with Tokio and smol runtime backends, and any other runtime can be plugged in by implementing one trait.
At a glance
- What is it?
- webrtc-rs/webrtc splits WebRTC into a Sans-I/O protocol core in the separate rtc crate and an async layer built from PeerConnection, PeerConnectionDriver and a Runtime trait, which puts the runtime and crypto choices per connection rather than per process.
- Who is it for?
- Pick this crate if you want the WebRTC protocol handled outside your executor, want per connection control over timers, sockets and crypto providers, or need a mock runtime for tests. Budget for reading the example tree yourself, and read the README sections on Release lines and Building and Testing.
- Can I use it commercially?
- Yes. Apache-2.0 is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 15 days ago.
- What is it written in?
- Mainly Rust, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on November 21, 2026, and from our analysis. They are not legal advice.
Star history
- webrtc-rs/webrtc5,189 ★ · +90
| Repository | 2026-07-31 | 2026-11-21 |
|---|---|---|
| webrtc-rs/webrtc | 5.1k | 5.2k |
90 Stars in the last 113 days, measured from the daily GitHub snapshot. Compare with other projects
Editorial analysis
A Sans-I/O core in rtc with a thin async shell on top
WebRTC.rs began as a rewrite of the Pion stack and now ships as two crates that divide the work. The rtc crate holds the Sans-I/O protocol core with the complete WebRTC stack, and the webrtc crate you depend on is a thin async layer over it. The async side comes down to three types, and knowing which one does what saves a lot of confusion. PeerConnection is the handle your application uses, and every operation on it is async: creating offers and answers, adding tracks, opening data channels. PeerConnectionDriver is an internal background event loop, spawned for you, that owns the sockets, drives the rtc core, handles timeouts and dispatches events. Runtime is the trait that abstracts timers, task spawning and sockets, and that trait is the reason the crate can sit on more than one executor. The core claims 95 percent or better W3C API compliance and lives in its own repository. Design details and a roadmap sit in an architecture post on webrtc.rs from January 2026.
Runtime and crypto features are additive, so switching means carrying two stacks
Cargo features here are additive rather than exclusive, and that choice has a price. Enabling a runtime feature only makes a built-in implementation of the Runtime trait available; it never selects which primitives the library uses. A build can therefore enable several at once, and one process can drive different connections on different runtimes. Crypto works the same way: enabling both providers compiles both, while ring stays the default selection, so a dependency that turns on crypto-aws-lc-rs cannot quietly change which provider your application runs. The cost is build weight. Turn on runtime-tokio and runtime-smol and both executor trees compile; turn on both crypto features and two cryptographic providers end up in your build even though only one is selected. runtime-mock is the odd one out, a MockRuntime with a deterministic virtual clock that performs no I/O.
| Feature | Default | Description | | --- | --- | --- | | `runtime-tokio` | yes | Timers, task spawning and sockets via Tokio | | `runtime-smol` | no | The same, via smol | | `runtime-mock` | no | `MockRuntime`, a deterministic virtual-clock runtime for tests (no I/O) | | `crypto-ring` | yes | The `ring`-based crypto provider | | `crypto-aws-lc-rs` | no | The `aws-lc-rs`-based crypto provider |
Crypto is picked per connection through SettingEngine, and none of it runs in this crate
No cryptography happens in the async crate. It forwards the provider you hand it to rtc, and the choice is made per connection through SettingEngine, which also means two connections inside one process can use different providers.
```rust,ignore use std::sync::Arc; use webrtc::peer_connection::SettingEngineBuilder; use webrtc::peer_connection::crypto;
let setting_engine = SettingEngineBuilder::new() .with_crypto_provider(Arc::new(crypto::providers::AwsLcRsProvider::new())) .build(); ```
Beyond the two built-ins, anything satisfying crypto::RTCCryptoProvider can be passed the same way, which is the route for a FIPS-validated module, an HSM, or a platform backend. The rtc-crypto conformance suite validates an implementation against the same RFC vectors the built-ins pass, so a custom provider can be checked rather than trusted. One failure mode deserves a name: build with neither crypto feature and no provider is compiled at all, leaving your application to supply one.
with_runtime is the seam that keeps your executor out of your own types
Runtime is the trait that decides what the crate sits on, modelled on Quinn's abstraction: timers, task spawning, sockets, DNS. Tokio is the default, smol ships next to it, and any third-party runtime works today by implementing the trait. You hand yours in per connection with with_runtime, with no cfg edits and no fork of the crate. The custom-runtime example runs the whole stack on async-executor plus async-io under --no-default-features, so neither Tokio nor smol is even compiled in, and that example is the quickest way to see what an implementation has to cover. There is a typing consequence at the API edge as well. build() returns an opaque impl PeerConnection, and PeerConnection is object safe, so storing the connection in a struct or sharing it across tasks means wrapping it as Arc<dyn PeerConnection>.
```rust,ignore let pc: Arc<dyn PeerConnection> = Arc::new(pc); ```
Either way no runtime or interceptor type parameters leak into your own types.
The examples tree is the usable documentation, and its count misses the advertised one
The repository layout says where the real documentation lives. The core lives in its own directory next to the async crate.
.devcontainer/
.github/
.gitignore
.gitmodules
.vscode/
CHANGELOG.md
Cargo.toml
LICENSE-APACHE
LICENSE-MIT
README.md
codecov.yml
docs/
examples/
rtc
scripts/
src/
tests/The example tree is the closest thing to a manual and reads best as one. The README points readers to 39 runnable examples. The data channel family is the deepest: data-channels, data-channels-create, data-channels-close, data-channels-simple, data-channels-offer-answer, data-channels-flow-control, data-channels-flow-control-multi, plus a data-channels-stress-bench. Media playback splits by codec, with play-from-disk-h26x, play-from-disk-vpx and play-from-disk-fec, alongside play-from-disk-playlist-control and play-from-disk-renegotiation. ICE coverage includes ice-tcp, ice-tcp-active-passive, ice-restart and mdns-query-and-gather, which matters because candidate gathering is where most debugging happens. Insertable streams, reflect, broadcast, rtcp-processing and bandwidth-estimation-from-disk are among the others.
What the manifest pulls in, and why the primitives are not feature gated
The manifest says what a build actually costs. The package is webrtc at version 0.21.1, edition 2024, licensed MIT/Apache-2.0, with LICENSE-MIT and LICENSE-APACHE both in the tree, and it categorises itself under network-programming with the keywords sansio, networking and protocols. The dependency on rtc is pinned to version 0.21.1 and declared with default-features = false, which is the mechanism behind the additive flags: this crate forwards feature selection instead of deciding the core's configuration.
[dependencies]
rtc = { version = "0.21.1", path = "rtc", default-features = false }
bytes = "1.12.0"
async-trait = "0.1.89"
log = "0.4.33"
futures = "0.3.32"
async-channel = "2.5.0"The note attached to that group is the part worth reading. Those are executor-agnostic primitives, plain data structures driven by wakers, they work on any runtime and they are deliberately not feature gated. Only reactor-bound operations, meaning timers, I/O and spawning, go through the Runtime trait. That split is why the default feature list is short.
default = ["runtime-tokio", "crypto-ring"]
runtime-tokio = ["dep:tokio"]
runtime-smol = ["dep:smol"]
runtime-mock = []
crypto-ring = ["rtc/crypto-ring"]
crypto-aws-lc-rs = ["rtc/crypto-aws-lc-rs"]Version 0.21.0 on master, with release line policy off the visible page
The version numbers have moved fast. v0.21.1 shipped on 11 October 2026, after v0.21.0 on 19 September 2026 and v0.21.0-rc.2 on 4 September 2026, and the last push to master landed on 1 November 2026 with the repository unarchived. So the manifest version on master, 0.21.1, matches the newest published tag instead of trailing it. The crate is below 1.0, which is the number to weigh before you pin. The page has a Semantic Versioning section in its table of contents, and that is where the policy belongs. The same table of contents lists Release lines, What's in 0.21, How to Provide Feedback, Building and Testing, Open Source License and Contributing, which is where release line policy and build commands are covered.
Editorial conclusion
Pick this crate if you want the WebRTC protocol handled outside your executor, want per connection control over timers, sockets and crypto providers, or need a mock runtime for tests. Budget for reading the example tree yourself, and read the README sections on Release lines and Building and Testing. Before pinning a version, check whether the 0.21 line matches what your code expects, since the crate is still below 1.0.
Frequently asked questions
How do I install the webrtc crate and which features do I get?
Add `webrtc = "0.21.0"` under `[dependencies]`. The default feature set is `runtime-tokio` and `crypto-ring`, so a plain dependency line gives you the Tokio runtime and the ring based crypto provider. The package and its API docs are published on crates.io and docs.rs.
How do I use webrtc from a Rust application?
Implement PeerConnectionEventHandler to receive events, build the connection with PeerConnectionBuilder and build(), and wrap the result as `Arc<dyn PeerConnection>` when you need to store or share it. The example tree covers data channels, ICE restart, insertable streams and media playback.
How is the webrtc internals split up?
Three types carry the async side: PeerConnection as the async handle, PeerConnectionDriver as the background event loop that owns the sockets and drives the Sans-I/O core, and the Runtime trait covering timers, task spawning, sockets and DNS. The protocol core itself is the separate rtc crate.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/webrtc-rs-webrtc)Star history chart for your README
[](https://hysenlabs.com/projects/webrtc-rs-webrtc)Was this useful?