REACT NATIVE • VIDEO CALLING • STEP-BY-STEP

How to add video calling to a React Native app

Build a one-to-one video call in React Native with the RTCExpress video calling SDK from npm. You will have two Android phones on a video call with full-screen remote video, a small self-view, mute, camera on/off, camera flip and hang up, without running WebRTC, TURN or media servers yourself.

Video calling needs the Pro planVideo calls and screen share are part of Pro ($29/month or $290/year, 10,000 video minutes a month). You can buy it from Billing in the customer console by card or UPI. On the Free plan the server answers a video call with plan_feature_denied; build the React Native voice calling tutorial first, which works on Free. See pricing.

1. What you need

  • A working React Native Android setup (Node.js, JDK 17 and Android Studio). React Native 0.73 or newer.
  • Two Android phones with cameras, Android 7.0 (API 24) or newer. Emulators work, but their virtual cameras show a test pattern.
  • An RTCExpress project on the Pro plan. Its App ID is in the customer console.

The RTCVideoView component is Android-only today; on iOS it throws an error. The SDK is a native module, so it does not run in Expo Go; use a React Native CLI project.

2. Create an app and install the SDK

Create a new React Native project and add rtcexpress-react-native:

npx @react-native-community/cli@latest init VideoCallDemo
cd VideoCallDemo
npm install rtcexpress-react-native

Autolinking adds the native module, so you don't edit Gradle files or AndroidManifest.xml. The package already declares the internet, camera and microphone permissions; your app only asks the user at runtime, which the code below does.

3. Create two test tokens

Log in to your customer console → Token tools and create two short-lived tokens in the same project and room:

  • User ID alice, room ID video-test.
  • User ID bob, room ID video-test.

Create config.ts next to App.tsx and paste in your App ID and both tokens:

// Test values from the console's Token tools.
// In a real app, fetch the token from your own backend. Never ship an App Secret.
export const APP_ID = 'YOUR_APP_ID';
export const ROOM_ID = 'video-test';
export const TOKENS: Record<'alice' | 'bob', string> = {
  alice: 'ALICE_TOKEN',
  bob: 'BOB_TOKEN',
};
Use user tokens, never your App SecretTest tokens expire, which is what you want. Your App Secret must never be built into a mobile app, because anyone can extract it from the APK.

4. Write the video call screen

Replace App.tsx with this. It is the whole app: pick a user, connect, join a room, place or answer a video call, and see both cameras.

import React, { useEffect, useRef, useState } from 'react';
import { Button, PermissionsAndroid, SafeAreaView, StyleSheet, Text, View } from 'react-native';
import RTCExpress, { RTCVideoView } from 'rtcexpress-react-native';
import { APP_ID, ROOM_ID, TOKENS } from './config';

type User = 'alice' | 'bob';
type CallStatePayload = { state: string; peerUserId: string };
type ErrorPayload = { message: string };

export default function App() {
  const rtc = useRef(new RTCExpress()).current;
  const [me, setMe] = useState<User | null>(null);
  const [status, setStatus] = useState('Pick a user');
  const [joined, setJoined] = useState(false);
  const [incoming, setIncoming] = useState(false);
  const [inCall, setInCall] = useState(false);
  const [connected, setConnected] = useState(false);
  const [muted, setMuted] = useState(false);
  const [cameraOff, setCameraOff] = useState(false);
  const peer: User = me === 'alice' ? 'bob' : 'alice';

  useEffect(() => {
    rtc.on('roomJoined', () => {
      setJoined(true);
      setStatus(`Joined ${ROOM_ID}`);
    });
    rtc.on('callInvite', () => setIncoming(true));
    rtc.on('callState', (p) => {
      const { state } = p as CallStatePayload;
      setStatus(`Call ${state}`);
      const active = state === 'ringing' || state === 'connecting' || state === 'connected';
      setInCall(active);
      setConnected(state === 'connected');
      if (state !== 'ringing') setIncoming(false);
      if (!active) {
        setMuted(false);
        setCameraOff(false);
      }
    });
    rtc.on('error', (p) => setStatus(`Error: ${(p as ErrorPayload).message}`));
    return () => rtc.destroy();
  }, [rtc]);

  async function connect(user: User) {
    // Ask for the camera and microphone together, before the first call.
    const result = await PermissionsAndroid.requestMultiple([
      PermissionsAndroid.PERMISSIONS.CAMERA,
      PermissionsAndroid.PERMISSIONS.RECORD_AUDIO,
    ]);
    if (!Object.values(result).every((r) => r === PermissionsAndroid.RESULTS.GRANTED)) {
      setStatus('Allow camera and microphone access to make video calls');
      return;
    }
    setMe(user);
    setStatus('Connecting...');
    try {
      await rtc.init({
        serverUrl: 'https://api.devsquarelabs.com',
        appId: APP_ID,
        userId: user,
        token: TOKENS[user],
        mediaMode: 'p2p', // 1:1 video goes directly between the two phones
      });
      rtc.joinRoom(ROOM_ID);
    } catch (e) {
      setStatus(`Error: ${(e as Error).message}`);
    }
  }

  return (
    <SafeAreaView style={styles.screen}>
      <Text style={styles.title}>{me ? `Video call: ${me}` : 'Video call demo'}</Text>
      <Text style={styles.status}>{status}</Text>
      <View style={styles.video}>
        {connected ? (
          <>
            <RTCVideoView style={StyleSheet.absoluteFill} />
            <RTCVideoView local style={styles.selfView} />
          </>
        ) : (
          <Text style={styles.placeholder}>Video appears here when the call connects</Text>
        )}
      </View>
      <View style={styles.buttons}>
        {!me && (
          <>
            <Button title="I am Alice" onPress={() => connect('alice')} />
            <Button title="I am Bob" onPress={() => connect('bob')} />
          </>
        )}
        {joined && !inCall && <Button title={`Video call ${peer}`} onPress={() => rtc.callUser(peer, true)} />}
        {incoming && (
          <>
            <Button title="Accept" onPress={() => rtc.acceptCall()} />
            <Button title="Reject" color="#b42318" onPress={() => rtc.rejectCall()} />
          </>
        )}
        {inCall && !incoming && (
          <>
            <Button
              title={muted ? 'Unmute' : 'Mute'}
              onPress={() => {
                rtc.muteMicrophone(!muted);
                setMuted(!muted);
              }}
            />
            <Button
              title={cameraOff ? 'Camera on' : 'Camera off'}
              onPress={() => {
                rtc.muteCamera(!cameraOff);
                setCameraOff(!cameraOff);
              }}
            />
            <Button title="Flip camera" onPress={() => rtc.switchCamera()} />
            <Button title="End call" color="#b42318" onPress={() => rtc.endCall()} />
          </>
        )}
      </View>
    </SafeAreaView>
  );
}

const styles = StyleSheet.create({
  screen: { flex: 1, padding: 16 },
  title: { fontSize: 22, fontWeight: '600', textAlign: 'center' },
  status: { marginTop: 8, marginBottom: 12, textAlign: 'center' },
  video: { flex: 1, backgroundColor: '#111', borderRadius: 12, overflow: 'hidden', justifyContent: 'center' },
  selfView: { position: 'absolute', top: 12, right: 12, width: 110, height: 150 },
  placeholder: { color: '#bbb', textAlign: 'center' },
  buttons: { gap: 10, marginTop: 12 },
});

How it works

  • init connects with a short-lived user token. mediaMode: 'p2p' sends video directly between the two phones, through a hosted TURN relay when a direct path isn't possible.
  • joinRoom asks to join. Membership is confirmed by the roomJoined event, so the call button only appears after it fires.
  • callUser(peer, true) rings the other user with a video call. On their phone, callInvite fires and they can acceptCall or rejectCall.
  • <RTCVideoView /> shows the other person and <RTCVideoView local /> shows your own camera. They are native Android views, so give them a size with a style. The self-view is drawn on top of the remote video by default.
  • muteCamera turns your camera off and on, switchCamera flips between front and back, muteMicrophone mutes audio and endCall hangs up.
  • destroy runs when the screen unmounts. It ends any call and closes the connection.

5. Run it on two phones

Connect both phones and list them with adb devices. Start Metro in one terminal:

npx react-native start

In a second terminal, install the app on each phone:

npx react-native run-android --deviceId FIRST_DEVICE_ID
npx react-native run-android --deviceId SECOND_DEVICE_ID
  1. On the first phone press I am Alice, and on the second press I am Bob. Allow camera and microphone access and wait for Joined video-test.
  2. On Alice's phone, press Video call bob.
  3. On Bob's phone, press Accept.
  4. When the status shows Call connected, each phone shows the other person and its own camera in the corner. Try Camera off, Flip camera, Mute and End call.

Two phones next to each other will echo; use headphones, or move apart.

Troubleshooting

  • Error plan_feature_denied when calling: video needs the Pro plan on this project. Check Billing in the console.
  • "rtcexpress-react-native doesn't seem to be linked": stop the app and run npx react-native run-android again (a Metro reload is not enough), and don't use Expo Go.
  • Call connects but the video area is black: check that camera permission was allowed in Android settings and that no other app is using the camera.
  • "RTCVideoView currently supports Android only": you are running on iOS, where the video view isn't available yet.
  • Call button never appears: both tokens must be for the same room, video-test, and must not be expired.
  • No incoming call: the user IDs in the tokens must be exactly alice and bob, and both phones must be connected.

6. Before you ship

Replace config.ts with a call to your own backend. Your server signs the user in, checks they may join the room, and requests a short-lived token from POST https://api.devsquarelabs.com/v1/token with your App ID and App Secret; the Node.js server SDK does this in a few lines. The App Secret stays on the server.

Then test across Wi-Fi and mobile data, with denied permissions, a rejected call, an expired token, and an app that goes into the background. During a call the SDK shows an "Ongoing call" notification so the call keeps working in the background. Ringing a phone while the app is closed needs push notifications; see the React Native incoming call guide. To share the phone screen during the call, see the screen sharing guide.

React Native video calling questions

Do I need my own WebRTC, TURN or media server?

No. RTCExpress hosts signaling, STUN, TURN relays and media servers. The React Native SDK connects to them with the token your backend issues.

Is there a ready-made call screen?

Yes. The SDK also exports CallScreen and the useRTCCall hook, which handle ringing, accept, mute and hang up for you. This tutorial builds the screen by hand so you can see each step; the React Native SDK guide shows the ready-made version.

How are video minutes counted?

In participant minutes: a two-person video call lasting ten minutes uses twenty. Pro includes 10,000 video minutes and 50,000 voice minutes a month. See pricing.

Can I do group video calls?

Yes. joinVideoRoom() joins group video in the current room, and <RTCVideoView userId="bob" /> shows one person's camera per tile. See the React Native SDK guide.