Registry / http-networking / webrtc-adapter-test

webrtc-adapter-test

JSON →
library0.2.10jsnpmunverified

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-test
INSTALL
IMPORT
SIG · WEBRTC-ADAPTER-TES
W
webrtc-adapter-test
http-networkingjavascriptv0.2.10
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

adapter (global)
✓ <!-- included via script tag -->
✗ import adapter from 'webrtc-adapter'; // when using script tag
When included via a `<script>` tag, the `adapter` object is typically exposed globally on `window.adapter`. This is often derived from `node_modules/webrtc-adapter/out/adapter.js`.
adapter (ESM)
✓ import adapter from 'webrtc-adapter';
✗ const adapter = require('webrtc-adapter'); // For modern browser builds (ESM)
For module bundlers (Webpack, Rollup, Vite) or native ESM in browsers, import the default export. This approach does not expose a global `window.adapter` by default.
adapter (CJS)
✓ const adapter = require('webrtc-adapter');
✗ import adapter from 'webrtc-adapter'; // In CommonJS environments (Node.js/older bundlers)
For CommonJS environments, `require` is the correct method. The adapter primarily shims browser APIs, so its direct use in Node.js might be limited to utility functions like `browserDetails`.
adapter.browserDetails
✓ console.log(adapter.browserDetails.browser);
✗ console.log(window.browserDetails.browser); // Not a direct global
The `browserDetails` object, containing `browser` and `version` properties, is accessed via the `adapter` object to detect the WebRTC engine.

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.

import adapter from 'webrtc-adapter'; const localVideo = document.createElement('video'); localVideo.autoplay = true; localVideo.muted = true; document.body.appendChild(localVideo); console.log('WebRTC Adapter loaded. Browser:', adapter.browserDetails.browser, 'Version:', adapter.browserDetails.version); const startMedia = async () => { try { const stream = await navigator.mediaDevices.getUserMedia({ video: true, audio: true }); localVideo.srcObject = stream; console.log('Local stream acquired and displayed.'); } catch (e) { console.error('Error accessing media devices:', e); alert(`Error accessing media: ${e.name} - ${e.message}`); } }; startMedia();
Debug
Known issues
gotchaThe package `webrtc-adapter-test` is an internal or deprecated testing package (version 0.2.10). For production use and active development, install and use the `webrtc-adapter` package (latest is 9.0.4).
fix
Use `npm install webrtc-adapter` and `import adapter from 'webrtc-adapter';`.
affects: <=0.2.10 (for -test package)
breakingMajor version updates of `webrtc-adapter` can introduce breaking changes, such as the removal of legacy shims (e.g., `navigator.getDisplayMedia` shim was removed) or modifications to API function signatures (`getStats`). These changes align with WebRTC specification evolution, but can break older applications.
fix
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.
affects: >=6.0
gotchaWhen bundling for the browser, be aware of the different output files: `adapter.js` exposes the `adapter` object globally on `window.adapter`, while `adapter_no_global.js` does not. Choose the correct file based on whether you expect a global object or plan to import it as a module.
fix
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.
affects: >=1.0
deprecatedDirect browser prefix usage (e.g., `navigator.webkitGetUserMedia`) is deprecated. While the adapter historically handled these, modern WebRTC development should target the standard `navigator.mediaDevices.getUserMedia` and `RTCPeerConnection` APIs, letting the adapter manage subtle browser differences.
fix
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.
affects: All versions
Errors
Common errors & fixes
ReferenceError: adapter is not defined
Attempting to access the `adapter` object without properly importing it in a module environment or before its script tag has executed in a global environment.
fix
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`.
TypeError: navigator.mediaDevices is undefined
Accessing `navigator.mediaDevices` in an older browser or a browser context where it's not yet defined, or when the `webrtc-adapter` shim has not been properly applied.
fix
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.
Upgrade
Version history
0.2.10latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
16 hits · last 30 days
node
14
OpenAI (training)
1
Resources