{"id":14364,"library":"wrtc","title":"WebRTC Implementation for Node.js","description":"wrtc provides a standards-compliant WebRTC implementation for Node.js, currently binding to WebRTC M81 (as of v0.4.7). This library leverages N-API (since v0.4.0) to ensure ABI stability across various Node.js releases, significantly enhancing compatibility and reducing issues often associated with native addons and Node.js version updates. The project prioritizes spec-compliance, validating its API behavior against the W3C's web-platform-tests project, making it a reliable choice for server-side WebRTC applications. Releases generally align with new WebRTC M-milestones and Node.js version support, indicating an active and well-maintained project cadence. It differentiates itself by offering a direct, low-level WebRTC API within the Node.js runtime, enabling scenarios like media processing, signaling servers, and peer-to-peer connections outside of a browser environment, and also includes nonstandard APIs for testing purposes. The current stable version is 0.4.7, continuously updated for Node.js compatibility and WebRTC feature parity.","status":"active","version":"0.4.7","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/node-webrtc/node-webrtc","tags":["javascript","webrtc","p2p","peer"],"install":[{"cmd":"npm install wrtc","lang":"bash","label":"npm"},{"cmd":"yarn add wrtc","lang":"bash","label":"yarn"},{"cmd":"pnpm add wrtc","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"While CommonJS `require('wrtc')` is possible, direct named imports are preferred in modern Node.js and TypeScript for clarity. Alternatively, `const wrtc = require('wrtc'); const pc = new wrtc.RTCPeerConnection();` is also common.","wrong":"const RTCPeerConnection = require('wrtc').RTCPeerConnection;","symbol":"RTCPeerConnection","correct":"import { RTCPeerConnection } from 'wrtc';"},{"note":"WebRTC classes like RTCSessionDescription are exposed directly from the main 'wrtc' package, mirroring browser global availability, not from sub-paths.","wrong":"const SessionDescription = require('wrtc/sdp').RTCSessionDescription;","symbol":"RTCSessionDescription","correct":"import { RTCSessionDescription } from 'wrtc';"},{"note":"Ensure correct capitalization and full name as per WebRTC API specification.","wrong":"import { IceCandidate } from 'wrtc';","symbol":"RTCICECandidate","correct":"import { RTCICECandidate } from 'wrtc';"}],"quickstart":{"code":"import { RTCPeerConnection } from 'wrtc';\n\nasync function createPeerConnectionDemo() {\n  const pc1 = new RTCPeerConnection();\n  const pc2 = new RTCPeerConnection();\n\n  // Exchange ICE candidates\n  pc1.onicecandidate = e => {\n    if (e.candidate) {\n      console.log('PC1 ICE Candidate:', e.candidate.candidate);\n      pc2.addIceCandidate(e.candidate).catch(err => console.error('Error adding ICE candidate to PC2:', err));\n    }\n  };\n  pc2.onicecandidate = e => {\n    if (e.candidate) {\n      console.log('PC2 ICE Candidate:', e.candidate.candidate);\n      pc1.addIceCandidate(e.candidate).catch(err => console.error('Error adding ICE candidate to PC1:', err));\n    }\n  };\n\n  // Log connection state changes\n  pc1.onconnectionstatechange = () => console.log('PC1 connection state:', pc1.connectionState);\n  pc2.onconnectionstatechange = () => console.log('PC2 connection state:', pc2.connectionState);\n\n  // Setup DataChannel communication\n  const dc1 = pc1.createDataChannel('chat');\n  dc1.onopen = () => console.log('PC1 DataChannel open!');\n  dc1.onmessage = e => console.log('PC1 received:', e.data);\n  dc1.onclose = () => console.log('PC1 DataChannel closed.');\n\n  pc2.ondatachannel = e => {\n    const dc2 = e.channel;\n    console.log('PC2 received DataChannel:', dc2.label);\n    dc2.onopen = () => console.log('PC2 DataChannel open!');\n    dc2.onmessage = e => console.log('PC2 received:', e.data);\n    dc2.onclose = () => console.log('PC2 DataChannel closed.');\n    dc2.send('Hello from PC2: Initial message!');\n  };\n\n  try {\n    // Create offer from PC1\n    const offer = await pc1.createOffer();\n    await pc1.setLocalDescription(offer);\n    console.log('PC1 Local Description (Offer) set.');\n\n    // Set offer on PC2 and create answer\n    await pc2.setRemoteDescription(pc1.localDescription);\n    console.log('PC2 Remote Description (Offer) set.');\n    const answer = await pc2.createAnswer();\n    await pc2.setLocalDescription(answer);\n    console.log('PC2 Local Description (Answer) set.');\n\n    // Set answer on PC1\n    await pc1.setRemoteDescription(pc2.localDescription);\n    console.log('PC1 Remote Description (Answer) set.');\n\n    console.log('Offer/Answer exchange complete. Waiting for ICE candidates and DataChannel open...');\n\n    // Send a message from PC1 after channels are likely open\n    setTimeout(() => {\n      if (dc1.readyState === 'open') {\n        dc1.send('Hello from PC1: How are you?');\n      } else {\n        console.warn('PC1 DataChannel not yet open to send message.');\n      }\n    }, 5000);\n\n  } catch (error) {\n    console.error('WebRTC setup failed:', error);\n  }\n}\n\ncreatePeerConnectionDemo();","lang":"javascript","description":"Demonstrates setting up two RTCPeerConnections locally in Node.js, exchanging SDP offer/answer, ICE candidates, and establishing a basic RTCDataChannel for message exchange."},"warnings":[{"fix":"Remove `dtx`, `ptime`, and `codecPayloadType` from `RTCRtpEncodingParameters` objects. Consult the latest WebRTC 1.0 specification for current valid parameters.","message":"With the update from WebRTC M79 to M81 in `wrtc` v0.4.5, the `dtx`, `ptime`, and `codecPayloadType` parameters to `RTCRtpEncodingParameters` no longer take effect. They have been removed from the WebRTC 1.0 specification and are now ignored.","severity":"breaking","affected_versions":">=0.4.5"},{"fix":"Ensure your Node.js and Electron versions are within the supported ranges listed in the documentation. For ARM architectures (e.g., Raspberry Pi), set `TARGET_ARCH` to 'arm' or 'arm64' before running `npm install wrtc`. If issues persist, refer to the 'build from source' guide.","message":"Installing `wrtc` requires prebuilt binaries or building from source. Incorrect `TARGET_ARCH` environment variable or an unsupported Node.js/Electron version can lead to installation failures or runtime errors due to missing or incompatible binaries.","severity":"gotcha","affected_versions":">=0.4.0"},{"fix":"Upgrade your Node.js environment to a supported version (e.g., Node.js ^8.11.2 || >=10.0.0, up to 14 as of 0.4.7) or use an older version of the `wrtc` package compatible with your environment.","message":"`wrtc` v0.4.0 transitioned to N-API and dropped support for older Node.js and Electron versions (specifically Node versions earlier than 8.11.2, 10.0.0 and Electron versions earlier than 4).","severity":"breaking","affected_versions":">=0.4.0"},{"fix":"Ensure you are using `wrtc` version 0.4.1 or newer to benefit from memory leak fixes related to `RTCDataChannel` string reception. Always test high-volume scenarios carefully.","message":"Memory leaks have been reported and fixed in specific scenarios, such as when receiving strings over `RTCDataChannel` in v0.4.0 and earlier. While fixes are applied, large-scale or long-running `RTCDataChannel` usage should be monitored for memory consumption.","severity":"gotcha","affected_versions":"<0.4.1"}],"env_vars":null,"search_vec":"'0.4.7':153 'abi':33 'across':35 'activ':99 'addon':49 'align':86 'also':141 'api':28,62,117,144 'applic':83 'associ':46 'behavior':63 'bind':16 'browser':138 'cadenc':105 'choic':77 'compat':41,158 'complianc':59 'compliant':10 'connect':134 'continu':154 'current':15,149 'differenti':107 'direct':112 'enabl':122 'enhanc':40 'ensur':32 'environ':139 'featur':161 'general':85 'implement':2,12 'includ':142 'indic':97 'issu':44 'javascript':163 'level':115 'leverag':25 'librari':24 'like':124 'low':114 'low-level':113 'm':91 'm-mileston':90 'm81':19 'maintain':103 'make':73 'media':125 'mileston':92 'n':27 'n-api':26 'nativ':48 'new':88 'node.js':4,14,37,51,94,120,157 'nonstandard':143 'offer':110 'often':45 'outsid':135 'p2p':165 'pariti':162 'peer':131,133,166 'peer-to-p':130 'platform':70 'priorit':56 'process':126 'project':55,72,104 'provid':6 'purpos':147 'reduc':43 'releas':38,84 'reliabl':76 'runtim':121 'scenario':123 'server':80,128 'server-sid':79 'side':81 'signal':127 'signific':39 'sinc':29 'spec':58 'spec-compli':57 'stabil':34 'stabl':150 'standard':9 'standards-compli':8 'support':96 'test':71,146 'updat':53,155 'v0.4.0':30 'v0.4.7':22 'valid':60 'various':36 'version':52,95,151 'w3c':66 'web':69 'web-platform-test':68 'webrtc':1,11,18,82,89,116,160,164 'well':102 'well-maintain':101 'within':118 'wrtc':5","created_at":"2026-04-20T01:59:19.390304+00:00","updated_at":"2026-04-20T01:59:19.390304+00:00","problems":[{"fix":"Run `npm install wrtc` in your project directory. Verify your `NODE_PATH` environment variable if you're using a non-standard module resolution setup.","cause":"The `wrtc` package is not installed, or Node.js cannot locate the module.","error":"Error: Cannot find module 'wrtc'"},{"fix":"Check the `wrtc` documentation for supported platforms and Node.js versions. If using an ARM device, ensure you set `TARGET_ARCH=arm` or `TARGET_ARCH=arm64` before `npm install wrtc`. If a prebuilt binary isn't available, you may need to compile `wrtc` from source (`npm install wrtc --build-from-source`).","cause":"There is no prebuilt binary available for your specific operating system, architecture, or Node.js version combination, or the `TARGET_ARCH` was set incorrectly.","error":"Error: Prebuilt binary not found for wrtc@0.4.7 on [platform]-[arch]"},{"fix":"Ensure you are importing `RTCPeerConnection` correctly: `import { RTCPeerConnection } from 'wrtc';` for ESM, or `const { RTCPeerConnection } = require('wrtc');` for CommonJS. If you imported the whole module as an object, access it like `new wrtc.RTCPeerConnection()`.","cause":"The `RTCPeerConnection` class was not correctly imported or accessed from the `wrtc` module.","error":"TypeError: RTCPeerConnection is not a constructor"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.0.0.dev9","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/node-webrtc/node-webrtc","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/wrtc","openapi_spec":null,"status_page":null,"smithery":null,"categories":["http-networking","communication","serialization"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-18","install_tag":null}}