Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-native-webrtc-web-shim

Package Overview
Dependencies
Maintainers
2
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-webrtc-web-shim

A shim for React Native WebRTC to enable support for React Native Web

  • 1.0.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.3K
decreased by-7.43%
Maintainers
2
Weekly downloads
 
Created
Source

React Native WebRTC

React-Native-WebRTC-Web-Shim

npm version npm downloads Discourse topics

Add support for react-native-web to a react-native-webrtc app.

Getting Started

Use one of the following preferred package install methods to immediately get going.

npm: npm install react-native-webrtc-web-shim --save
yarn: yarn add react-native-webrtc-web-shim
pnpm: pnpm install react-native-webrtc-web-shim

Extra Required Steps

Import directly from our library instead of react-native-webrtc.

-import { RTCPeerConnection } from 'react-native-webrtc';
+import { RTCPeerConnection } from 'react-native-webrtc-web-shim';
RTCView

When displaying the RTCView component, pass it the stream object as a prop instead of streamURL.
On Web, this component renders an HTML5 video tag.

<RTCView
  -streamURL={stream.toURL()}
  +stream={stream}
/>
Track Listener

Add the ontrack listener to your RTCPeerConnection object, similar to the onaddstream listener.

// existing code, keep this for native support
webRtcPeer.onaddstream = async ({ stream }) => {
  await addVideo( sessionId, stream );
};

// add the ontrack listener for web support
webRtcPeer.ontrack = async ({ track, streams }) => {
  if ( track.kind === 'video' ) {
    await addVideo( sessionId, streams[ 0 ] );
  }
};

Community

Come join our Discourse Community if you want to discuss any React Native and WebRTC related topics.
Everyone is welcome and every little helps.

Looking for extra functionality coverage?
The react-native-webrtc organization provides a number of packages which are more than useful when developing Real Time Communication applications.

Keywords

FAQs

Package last updated on 01 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc