REACT NATIVE • SCREEN SHARING • GUIDE
Screen sharing in React Native (Android)
To share the phone's screen in a React Native video call, Android captures the screen with the MediaProjection API after the user agrees, a foreground service of type mediaProjection keeps the capture running, and WebRTC sends it to the others as a second video track next to the camera. This guide explains each part, shows the code with react-native-webrtc, and shows the two-line version with the RTCExpress React Native SDK, including the "screen big, cameras small" layout and what to test on real phones.
How screen sharing works on Android
- The user agrees. Your app asks Android for screen capture, and Android shows its own "Start recording or casting?" prompt. No app can skip it.
- A foreground service runs. From Android 10, screen capture is only allowed while a foreground service of type
mediaProjectionis running. It shows a notification, so the user always knows the screen is being shared. From Android 14, the service must be started before the capture, and each sharing session needs a new prompt. - WebRTC sends the screen as video. The capture becomes a video track. Send it as a separate track, so people can see your screen and your camera at the same time.
- The others show it big. The receiving apps need to know which video is a screen and which is a camera, so they can put the screen in the large view.
1. Permissions and the foreground service
Declare the foreground-service permissions and a service with the mediaProjection type:
<!-- android/app/src/main/AndroidManifest.xml -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PROJECTION" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<application ...>
<service
android:name=".ScreenShareService"
android:exported="false"
android:foregroundServiceType="mediaProjection" />
</application>The service only needs to show an ongoing notification ("Sharing your screen") while sharing. On Android 13 and newer, ask for the notification permission at runtime. If you publish on Google Play and target Android 14 or newer, fill in the Foreground service permissions form in Play Console and explain that the app shares the screen during a call.
2. Capture and send the screen with react-native-webrtc
If you run your own WebRTC calls, getDisplayMedia() in react-native-webrtc returns the screen as a video track:
import { mediaDevices } from "react-native-webrtc";
// 1. Start your own foreground service of type mediaProjection first (Android 10+),
// e.g. a small native module or a notification library that supports it.
await startScreenShareService();
// 2. Android shows "Start recording or casting?" and returns the screen as a video track
const stream = await mediaDevices.getDisplayMedia();
const screenTrack = stream.getVideoTracks()[0];
// 3. Send it to the other people in the call, next to (not instead of) the camera
peerConnection.addTrack(screenTrack, stream);
// 4. Stop: end the track, remove it from the call, stop the service
screenTrack.stop();
await stopScreenShareService();You still need to tell the other side that this track is a screen, not a camera (for example with a message over your signaling connection), handle the user tapping "Stop" in Android's own controls, renegotiate the call when the track is added and removed, and stop the foreground service every time sharing ends. In group calls you also need a media server (SFU), because sending a screen to every person separately uses too much of the phone's upload.
3. The two-line version with RTCExpress
The RTCExpress React Native SDK (version 0.1.2 or later) does all of the above for you: the Android prompt, the foreground service and notification, the separate screen track, telling everyone who is sharing, stopping cleanly, and sending through the media server in group calls. Web users of the web SDK see a phone's shared screen, and phones see a browser's.
import RTCExpress, { RTCVideoView } from "rtcexpress-react-native";
// In a 1:1 or group call (mediaMode "auto", the default):
rtc.startScreenShare(); // Android asks "Start recording or casting?", the SDK does the rest
rtc.stopScreenShare(); // also stops when the user taps Stop in Android's own controls
// Everyone in the call (phones and browsers) is told who is sharing
rtc.on("screenShare", ({ userId, active, local }) => setSharer(active ? userId : null));Show the shared screen big and the cameras small:
// The shared screen big, cameras small: the layout people expect
<View style={{ flex: 1, backgroundColor: "#000" }}>
<RTCVideoView screen userId={sharer} style={{ flex: 1 }} />
<View style={{ flexDirection: "row", gap: 8, padding: 8 }}>
<RTCVideoView userId={sharer} style={{ width: 96, height: 128 }} /> {/* their camera */}
<RTCVideoView local style={{ width: 96, height: 128 }} /> {/* you */}
</View>
</View>Screen sharing is on the Pro plan ($29/month plus tax, 10,000 video minutes, group video up to 8 cameras), the same for 1:1 and group calls.
4. Or use the ready-made call screen
The SDK's call screen already has a Share screen button, shows a red "You're sharing your screen" label, and switches to the "screen big, cameras small" layout when someone else shares. While sharing, people usually want to open another app or another page of yours: the back button minimizes the call, and the ongoing-call bar brings it back. The call keeps working in other apps and with the screen off.
import { useRTCCall, CallScreen, OngoingCallBar } from "rtcexpress-react-native";
const call = useRTCCall(rtc);
<View style={{ flex: 1 }}>
<OngoingCallBar call={call} /> {/* "Bob · 4:12 · Tap to return" while the call is minimized */}
<YourNavigation />
<CallScreen controller={call} /> {/* has a Share screen button; shows a shared screen big */}
</View>Test checklist
- Test on a real phone, not an emulator, on Android 10, 13 and 14 or newer if you can.
- Tap Share: Android's prompt appears, the notification shows, and the other person sees your screen big.
- Open another app while sharing: the other person sees that app, and the call keeps going.
- Stop from Android's own notification or status bar chip: sharing stops for everyone, and your app shows it stopped.
- Decline the prompt: nothing is shared, and your app doesn't get stuck in "sharing".
- Share in a group call with a browser user: both see each other's screens.
- Open a banking or streaming app while sharing: expect a black screen (that's Android protecting that app, not a bug).
Frequently asked questions
Can React Native share the phone's screen?
Yes, on Android. Android's MediaProjection API captures the screen after the user agrees in a system prompt, and WebRTC sends it as a video track. On Android 10 and newer, a foreground service of type mediaProjection must be running while you capture, and Android shows a notification while the screen is shared.
Why does Android ask for permission every time?
Screen capture can show anything on the phone, including passwords and messages, so Android asks the user each time sharing starts. From Android 14 the permission can't be reused for a second session: each share needs a new prompt. This can't be skipped.
Why do some apps show a black screen when shared?
Apps can mark their windows as secure (FLAG_SECURE), for example banking apps, password managers and streaming apps. Android replaces them with black in every screen capture, including screenshots. Nothing in your app can change that.
Is the phone's sound shared too?
Not by default. Screen sharing sends video. Other people still hear you through the call's microphone. Capturing other apps' audio needs the separate AudioPlaybackCapture API (Android 10+), and many apps don't allow it.
What about screen sharing on iPhone?
iOS can only share the whole screen through a ReplayKit Broadcast Upload Extension: a separate app extension with its own memory limit (about 50 MB) that sends the frames. It works, but it's a lot more setup than on Android. RTCExpress supports Android today; iOS is on the roadmap.
Does screen sharing use a lot of data?
A shared phone screen is usually sent at 15 frames per second, which needs about 1 to 1.5 Mbps while text must stay readable. Turn the camera off while sharing on slow networks; the call quality of everyone else stays the same.
Calls with screen sharing, without running servers
RTCExpress runs the call server, media server and TURN relay for you. Start with a free trial (1:1 voice and chat, no card needed), then add video and screen sharing on Pro.
Create free accountReact Native SDK guide