{"id":18767,"library":"rtcpeerconnection-shim","title":"RTCPeerConnection Shim for ORTC","description":"The rtcpeerconnection-shim package (v1.2.15) is a JavaScript library that provides a polyfill/shim implementing the W3C RTCPeerConnection API on top of the ORTC (Object RTC) API, which is used by Microsoft Edge (pre-Chromium). It allows developers to use the standard WebRTC RTCPeerConnection interface in environments that only support ORTC. The project is in maintenance mode, with its last release in 2018. It offers a compatibility layer, but it is limited compared to native WebRTC support. Key differentiator: it enables RTCPeerConnection in legacy Edge; however, it is no longer needed in modern browsers and has subtle API differences.","status":"maintenance","version":"1.2.15","language":"javascript","source_language":"en","source_url":"https://github.com/fippo/rtcpeerconnection-shim","tags":["javascript"],"install":[{"cmd":"npm install rtcpeerconnection-shim","lang":"bash","label":"npm"},{"cmd":"yarn add rtcpeerconnection-shim","lang":"bash","label":"yarn"},{"cmd":"pnpm add rtcpeerconnection-shim","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used for SDP-to-Jingle conversion required by ORTC","package":"sdp-jingle-json","optional":false},{"reason":"Adapter for ORTC API compatibility","package":"ortc-adapter","optional":false}],"imports":[{"note":"ESM named export; CommonJS require works but TypeScript may require esModuleInterop.","wrong":"const RTCPeerConnection = require('rtcpeerconnection-shim')","symbol":"RTCPeerConnection","correct":"import { RTCPeerConnection } from 'rtcpeerconnection-shim'"},{"note":"Named export, not default.","wrong":"import RTCSessionDescription from 'rtcpeerconnection-shim'","symbol":"RTCSessionDescription","correct":"import { RTCSessionDescription } from 'rtcpeerconnection-shim'"},{"note":"Also a named export; required for constructing ICE candidates.","wrong":"","symbol":"RTCIceCandidate","correct":"import { RTCIceCandidate } from 'rtcpeerconnection-shim'"}],"quickstart":{"code":"import { RTCPeerConnection, RTCSessionDescription, RTCIceCandidate } from 'rtcpeerconnection-shim';\n\nconst pc = new RTCPeerConnection({\n  iceServers: [{ urls: 'stun:stun.l.google.com:19302' }]\n});\n\npc.onicecandidate = (e) => {\n  if (e.candidate) {\n    console.log('ICE candidate:', e.candidate.candidate);\n  }\n};\n\nnavigator.mediaDevices.getUserMedia({ audio: true, video: true })\n  .then((stream) => {\n    stream.getTracks().forEach((track) => pc.addTrack(track, stream));\n    return pc.createOffer();\n  })\n  .then((offer) => pc.setLocalDescription(offer))\n  .catch((err) => console.error(err));","lang":"typescript","description":"Creates an RTCPeerConnection, gets user media, creates an offer, and logs ICE candidates."},"warnings":[{"fix":"Test extensively on target browsers; consider using adapter.js for cross-browser support.","message":"The peerconnection may behave differently than native WebRTC, e.g., no support for unified plan or some SDP attributes.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Remove this dependency if targeting only modern browsers; use standard WebRTC API directly.","message":"This shim is no longer needed for Edge Chromium (2020+). Modern Edge uses Chromium with native WebRTC.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Use `new RTCIceCandidate({ candidate: 'candidate string' })` instead of passing a string directly.","message":"The RTCIceCandidate constructor may not accept strings like in standard WebRTC; use object format.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Ensure the shim is loaded before creating any connections: import the module at the entry point of your app.","cause":"RTCPeerConnection not properly initialized or underlying ORTC not available.","error":"TypeError: Cannot read property 'createOffer' of null"},{"fix":"Check the signaling state (pc.signalingState) before setting descriptions. Typical flow: createOffer -> setLocalDescription -> wait for answer.","cause":"Attempting to call setLocalDescription multiple times without proper signaling state management.","error":"Failed to set local offer sdp: Called in wrong state: kStable"},{"fix":"Import 'rtcpeerconnection-shim' at the top of your script. For Node.js, ensure it's bundled correctly.","cause":"The shim was not imported or loaded before use, or environment doesn't support the shim.","error":"ReferenceError: RTCPeerConnection is not defined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}