Docs / React Native / WebRTC

WebRTC on React Native

Beautify a react-native-webrtc camera track through its video-effects API. One call registers Facevity and enables it on the track.

Demo app: facevity-react-native-demo on GitHub

react-native-webrtc 118 and later have a video-effects API (ProcessorProvider) that runs native processors on a track’s frames before they are encoded. Facevity registers a processor named facevity and enables it on your camera track.

1. Requirements

  • react-native-facevity set up as in the quick start
  • react-native-webrtc 118 or later
  • Detected automatically on Android and iOS

2. Attach to the camera track

import { mediaDevices, RTCPeerConnection, RTCView } from 'react-native-webrtc';
import { Beauty, Facevity } from 'react-native-facevity';

const fv = await Facevity.initialize({ licenseToken });
await fv.setParams(Beauty.NATURAL);

const stream = await mediaDevices.getUserMedia({ audio: true, video: { facingMode: 'user' } });
const track = stream.getVideoTracks()[0];
await fv.rtc.webrtc.attachTrack(track);                // = register + track._setVideoEffects(['facevity'])

stream.getTracks().forEach((t) => pc.addTrack(t, stream));

<RTCView streamURL={stream.toURL()} mirror objectFit="cover" style={{ flex: 1 }} />

The local RTCView and the encoder both receive the processed frames.

3. Tear down

await fv.rtc.webrtc.detach(track);
stream.getTracks().forEach((t) => t.stop());
pc.close();

Notes

  • Attach again if you create a new track (a new getUserMedia).
  • mirror on RTCView mirrors only the local view; the sent frames are never mirrored.

Next: all platforms · API reference

Need help with an integration? Contact the Facevity team. We answer integration questions during trials.