// the find
webrtc/samples
WebRTC Web demos and samples
The official sample collection from the WebRTC project itself, covering nearly every corner of the API: getUserMedia, peer connections, data channels, insertable streams/WebCodecs, device enumeration, perfect negotiation, screen capture. Best used as a reference implementation when you're stuck on 'how does the spec actually expect this to work,' not as something you install.
It's maintained by the people who write the spec and the Chrome implementation, so when the API changes (insertable streams, getDisplayMedia constraints, etc.) these samples get updated instead of going stale like most blog tutorials. Each demo is a self-contained folder with its own html/js/css, so you can copy exactly one thing without dragging in unrelated code. It's also live-hosted at webrtc.github.io/samples, so you can see the actual browser behavior before reading a line of code — useful for confirming whether a bug is your code or a browser quirk.
There is no shared module or npm package to import — every sample is copy-paste, and there's no consistent abstraction layer if you want more than one feature (say, data channels plus insertable streams) working together. Code style is inconsistent across ~80 folders since samples were added over a decade: some use modern async/await, others still use callback-style getUserMedia patterns. None of the samples handle the things that actually bite you in production — TURN fallback, ICE restart on network change, reconnection after a dropped peer connection are either absent or handled with a one-line comment. Test coverage (test.js) exists for maybe a third of the folders, not all of them.