{"library":"react-native-webrtc","title":"React Native WebRTC Module","description":"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.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install react-native-webrtc"],"cli":null},"imports":["import { RTCPeerConnection } from 'react-native-webrtc';","import { mediaDevices } from 'react-native-webrtc';","import { RTCView } from 'react-native-webrtc';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import React, { useEffect, useRef, useState } from 'react';\nimport { View, Text, Button, Platform, PermissionsAndroid, Alert } from 'react-native';\nimport {\n  RTCPeerConnection,\n  RTCIceCandidate,\n  RTCSessionDescription,\n  RTCView,\n  mediaDevices,\n} from 'react-native-webrtc';\n\nconst configuration = { iceServers: [{ url: 'stun:stun.l.google.com:19302' }] };\n\nexport default function App() {\n  const [localStream, setLocalStream] = useState<any>(null);\n  const pc = useRef<RTCPeerConnection | null>(null);\n\n  useEffect(() => {\n    (async () => {\n      if (Platform.OS === 'android') {\n        await PermissionsAndroid.requestMultiple([\n          PermissionsAndroid.PERMISSIONS.CAMERA,\n          PermissionsAndroid.PERMISSIONS.RECORD_AUDIO,\n        ]);\n      }\n\n      try {\n        const stream = await mediaDevices.getUserMedia({\n          audio: true,\n          video: {\n            mandatory: {\n              minWidth: '500',\n              minHeight: '300',\n              minFrameRate: '30',\n            },\n            facingMode: 'user',\n          },\n        });\n        setLocalStream(stream);\n\n        pc.current = new RTCPeerConnection(configuration);\n        pc.current.addStream(stream);\n\n        pc.current.onicecandidate = (event) => {\n          if (event.candidate) {\n            console.log('ICE Candidate:', event.candidate);\n            // In a real app, you would send this candidate to the remote peer\n          }\n        };\n\n        const offer = await pc.current.createOffer();\n        await pc.current.setLocalDescription(offer);\n        console.log('Local Offer:', offer.sdp);\n        // In a real app, you would send this offer to the remote peer\n      } catch (err: any) {\n        Alert.alert('Media Error', err.message);\n      }\n    })();\n\n    return () => {\n      if (localStream) {\n        localStream.release();\n      }\n      if (pc.current) {\n        pc.current.close();\n      }\n    };\n  }, []);\n\n  if (!localStream) {\n    return <Text>Loading local media...</Text>;\n  }\n\n  return (\n    <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>\n      <Text>Local Stream:</Text>\n      <RTCView streamURL={localStream.toURL()} style={{ width: 300, height: 200, backgroundColor: 'black' }} />\n      <Button title=\"Start Call (logic incomplete)\" onPress={() => Alert.alert('Simulated Call', 'Offer sent (check console)')} />\n    </View>\n  );\n}","lang":"typescript","description":"Demonstrates how to obtain local audio/video media, initialize an RTCPeerConnection, and display the local video stream using RTCView, including basic Android permission handling.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}