This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.

Expo ScreenCapture

A library that allows you to protect screens in your app from being captured or recorded.

Android
iOS
Included in Expo Go
Recommended version:
~56.0.5

expo-screen-capture allows you to protect screens in your app from being captured or recorded, as well as be notified if a screenshot is taken while your app is foregrounded. The two most common reasons you may want to prevent screen capture are:

  • If a screen is displaying sensitive information (password, credit card data, and so on)
  • You are displaying paid content that you don't want to be recorded and shared

This is especially important on Android since the android.media.projection API allows third-party apps to perform screen capture or screen sharing (even if the app is in the background).

On Android, the screen capture callback works without additional permissions only for Android 14+. You don't need to request or check permissions for blocking screen capture or using the callback on Android 14+.

If you want to use the screen capture callback on Android 13 or lower, you need to add the READ_MEDIA_IMAGES permission to your AndroidManifest.xml file. You can use the android.permissions key in your app config. See Android permissions for more information.

Installation

Terminal
- npx expo install expo-screen-capture
- yarn expo install expo-screen-capture
- pnpm expo install expo-screen-capture
- bun expo install expo-screen-capture

If you are installing this in an existing React Native app, make sure to install expo in your project.

Usage

Example: hook

Screen Capture hook
import { usePreventScreenCapture } from 'expo-screen-capture'; import { Text, View } from 'react-native'; export default function ScreenCaptureExample() { usePreventScreenCapture(); return ( <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}> <Text>As long as this component is mounted, this screen is unrecordable!</Text> </View> ); }

Example: Blocking screen capture imperatively

Blocking screen capture
import * as ScreenCapture from 'expo-screen-capture'; import { useEffect } from 'react'; import { Button, StyleSheet, View } from 'react-native'; export default function ScreenCaptureExample() { const activate = async () => { await ScreenCapture.preventScreenCaptureAsync(); }; const deactivate = async () => { await ScreenCapture.allowScreenCaptureAsync(); }; return ( <View style={styles.container}> <Button title="Activate" onPress={activate} /> <Button title="Deactivate" onPress={deactivate} /> </View> ); } const styles = StyleSheet.create({ container: { flex: 1, alignItems: 'center', justifyContent: 'center', }, });

Example: Callback for screen capture

Callback for screen capture
import * as ScreenCapture from 'expo-screen-capture'; import { useEffect } from 'react'; import { Button, StyleSheet, View } from 'react-native'; export default function useScreenCaptureCallback() { // Only use this if you add the READ_MEDIA_IMAGES permission to your AndroidManifest.xml const hasPermissions = async () => { const { status } = await ScreenCapture.requestPermissionsAsync(); return status === 'granted'; }; useEffect(() => { let subscription; const addListenerAsync = async () => { if (await hasPermissions()) { subscription = ScreenCapture.addScreenshotListener(() => { alert('Thanks for screenshotting my beautiful app 😊'); }); } else { console.error('Permissions needed to subscribe to screenshot events are missing!'); } }; addListenerAsync(); return () => { subscription?.remove(); }; }, []); }

API

import * as ScreenCapture from 'expo-screen-capture';

No API data file found, sorry!