Registry / communication / react-native-webrtc

react-native-webrtc

JSON →
library124.0.7jsnpmunverified

react-native-webrtc provides a comprehensive WebRTC implementation for React Native applications across Android, iOS, and tvOS. The library is currently stable at version 124.0.7 and follows a rapid release cadence, frequently updating to new WebRTC M-releases (e.g., M124). Key features include support for audio/video communication, data channels, and screen capture. A significant differentiator is its exclusive adoption of the Unified Plan as of version 106.0.0, requiring users of older Plan B to migrate or remain on previous releases. It also supports Simulcast since version 111.0.0 with software encode/decode factories enabled by default. While not officially supporting macOS or Windows, it offers a web shim for react-native-web and can be integrated into Expo projects via expo-dev-client and config plugins.

npm install react-native-webrtc
INSTALL
IMPORT
SIG · REACT-NATIVE-WEBRT
R
react-native-webrtc
communicationjavascriptv124.0.7
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
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 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

RTCPeerConnection
import { RTCPeerConnection } from 'react-native-webrtc';
const RTCPeerConnection = require('react-native-webrtc').RTCPeerConnection;
Use ES module imports; CommonJS 'require' is not the standard or recommended approach for this library, especially with TypeScript.
mediaDevices
import { mediaDevices } from 'react-native-webrtc';
import mediaDevices from 'react-native-webrtc';
mediaDevices is a named export, not the default export.
RTCView
import { RTCView } from 'react-native-webrtc';
import RTCVideoView from 'react-native-webrtc';
The correct component name for video rendering is RTCView. Ensure native modules are properly linked for this component to render.

Demonstrates how to obtain local audio/video media, initialize an RTCPeerConnection, and display the local video stream using RTCView, including basic Android permission handling.

import React, { useEffect, useRef, useState } from 'react'; import { View, Text, Button, Platform, PermissionsAndroid, Alert } from 'react-native'; import { RTCPeerConnection, RTCIceCandidate, RTCSessionDescription, RTCView, mediaDevices, } from 'react-native-webrtc'; const configuration = { iceServers: [{ url: 'stun:stun.l.google.com:19302' }] }; export default function App() { const [localStream, setLocalStream] = useState<any>(null); const pc = useRef<RTCPeerConnection | null>(null); useEffect(() => { (async () => { if (Platform.OS === 'android') { await PermissionsAndroid.requestMultiple([ PermissionsAndroid.PERMISSIONS.CAMERA, PermissionsAndroid.PERMISSIONS.RECORD_AUDIO, ]); } try { const stream = await mediaDevices.getUserMedia({ audio: true, video: { mandatory: { minWidth: '500', minHeight: '300', minFrameRate: '30', }, facingMode: 'user', }, }); setLocalStream(stream); pc.current = new RTCPeerConnection(configuration); pc.current.addStream(stream); pc.current.onicecandidate = (event) => { if (event.candidate) { console.log('ICE Candidate:', event.candidate); // In a real app, you would send this candidate to the remote peer } }; const offer = await pc.current.createOffer(); await pc.current.setLocalDescription(offer); console.log('Local Offer:', offer.sdp); // In a real app, you would send this offer to the remote peer } catch (err: any) { Alert.alert('Media Error', err.message); } })(); return () => { if (localStream) { localStream.release(); } if (pc.current) { pc.current.close(); } }; }, []); if (!localStream) { return <Text>Loading local media...</Text>; } return ( <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}> <Text>Local Stream:</Text> <RTCView streamURL={localStream.toURL()} style={{ width: 300, height: 200, backgroundColor: 'black' }} /> <Button title="Start Call (logic incomplete)" onPress={() => Alert.alert('Simulated Call', 'Offer sent (check console)')} /> </View> ); }
Debug
Known issues
breakingAs of version 106.0.0, 'react-native-webrtc' exclusively supports the Unified Plan. Applications relying on the older Plan B must either migrate to Unified Plan or remain on a version prior to 106.0.0.
fix
Refactor WebRTC signaling and session description handling to comply with Unified Plan specifications. Consult the WebRTC documentation for migration guides.
affects: >=106.0.0
breakingUVC camera support for Android was explicitly dropped in version 118.0.5. Devices using UVC cameras will no longer be compatible.
fix
Developers targeting Android devices with external cameras should verify compatibility or implement alternative camera handling if UVC is critical, potentially by staying on an older version or contributing a new implementation.
affects: >=118.0.5
gotchaThe `minSdkVersion` set by your app may conflict with the library's internal `minSdkVersion` handling on Android, potentially leading to build issues or unexpected behavior. Version 124.0.5 includes changes to address this by not using the app's `minSdkVersion`.
fix
Upgrade to version 124.0.5 or newer. If issues persist, ensure your `android/app/build.gradle` `minSdkVersion` is aligned with React Native's recommendations and any specific library requirements.
affects: <124.0.5
gotchaFor iOS compatibility with React Native versions 0.73 and above, you must use `react-native-webrtc` version 124.0.3 or higher. Older versions may lead to build errors or runtime instability.
fix
Update `react-native-webrtc` to version 124.0.3 or later to ensure compatibility with React Native 0.73+ on iOS.
affects: <124.0.3
gotchaAs a native module, `react-native-webrtc` requires proper linking of native components (e.g., for `RTCView`) on bare React Native projects. Skipping this step often results in runtime errors.
fix
Follow the platform-specific installation guides (Android, iOS) in the documentation to ensure all native modules are correctly linked and permissions are configured. For Expo, use `expo-dev-client` and the `config-plugins/react-native-webrtc` package.
affects: >=0.0.0
Errors
Common errors & fixes
Error: Permission denied
The application lacks necessary camera or microphone permissions for Android or iOS.
fix
On Android, request `PermissionsAndroid.PERMISSIONS.CAMERA` and `PermissionsAndroid.PERMISSIONS.RECORD_AUDIO`. On iOS, ensure `NSCameraUsageDescription` and `NSMicrophoneUsageDescription` are present in `Info.plist`.
TypeError: Cannot read property 'getUserMedia' of undefined
The `mediaDevices` object was not correctly imported or the native module for WebRTC is not properly linked/initialized, preventing access to media devices.
fix
Ensure `import { mediaDevices } from 'react-native-webrtc';` is present. Verify that you have run `npx react-native link` (if applicable) and followed all platform-specific native installation steps.
Invariant Violation: requireNativeComponent: 'RTCVideoView' was not found in the UIManager.
The native component `RTCView` (internally `RTCVideoView` in some contexts) is not correctly linked or registered with the React Native bridge.
fix
Confirm that you have completed all native installation steps for both Android and iOS, including running `pod install` for iOS and rebuilding your Android project after installing the package.
Upgrade
Version history
124.0.7latest on npm
Audit
Dependencies
react-nativerequiredRuntime dependency for the React Native environment.
Agent activity
14 hits · last 30 days
node
12
OpenAI (training)
1
Resources