The WebRTC Adapter, often referred to as `adapter.js`, is a critical JavaScript shim library designed to mitigate cross-browser inconsistencies and insulate applications from evolving WebRTC API specifications. While initial WebRTC implementations featured significant vendor prefixes (e.g., `webkitGetUserMedia`, `mozRTCPeerConnection`), these have largely converged to standard names. However, subtle behavioral differences and API quirks still persist across browsers like Chrome, Firefox, and Safari. The adapter transparently intercepts and normalizes these variations, allowing developers to write more consistent and future-proof WebRTC code without extensive browser-specific conditionals or polyfills. Currently, the actively maintained version is `9.0.4`, available via `webrtc-adapter` on npm. Maintained by WebRTC experts (under `webrtcHacks` on GitHub), it offers a stable and reliable solution for ensuring WebRTC applications function seamlessly across diverse environments. Its release cadence typically follows browser updates and WebRTC specification adjustments to maintain compatibility.
npm install webrtc-adapter-testVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to import and use the WebRTC Adapter, then acquire and display a local video and audio stream using `navigator.mediaDevices.getUserMedia` which the adapter may have shimmed. It also logs browser details detected by the adapter.
Use `npm install webrtc-adapter` and `import adapter from 'webrtc-adapter';`.
Always pin the exact version of `webrtc-adapter` in your `package.json` (e.g., `"webrtc-adapter": "^9.0.4"` to `"webrtc-adapter": "9.0.4"`) and thoroughly test when upgrading versions. Review release notes for breaking changes.
If using a script tag and expecting global access, ensure you are loading `adapter.js`. If using a module bundler, typically `import adapter from 'webrtc-adapter';` is sufficient, and a global is not exposed unless explicitly configured by the bundler or the `adapter.js` variant.
Always use the standard, unprefixed WebRTC APIs. The adapter will apply necessary shims behind the scenes. Regularly update the adapter to ensure support for the latest browser behaviors.
If using a module system (ESM/CommonJS), ensure you have `import adapter from 'webrtc-adapter';` or `const adapter = require('webrtc-adapter');` at the top of your file. If using a `<script>` tag, ensure the adapter script is loaded before your code that references `adapter`.Ensure `webrtc-adapter` is loaded and executed *before* any WebRTC API calls, especially `navigator.mediaDevices.getUserMedia`. The adapter polyfills `navigator.mediaDevices` for older browsers or contexts where it might be missing or prefixed. Also, check if the browser fundamentally supports WebRTC.
No dependency data recorded yet.