Press ESC to close

React native capture protection

  • Jun 28, 2026
  • 2 minutes read
  • 2 Views
 

react-native-capture-protection is a modern library for protecting sensitive content in React Native applications. 

It supports:

  1. ✅ Screenshot detection
  2. ✅ Screen recording detection
  3. ✅ Screenshot prevention (Android)
  4. ✅ Screen recording prevention (Android)
  5. ✅ Secure view (FLAG_SECURE) on Android
  6. ✅ Screen capture status detection on iOS

Installation

npm install react-native-capture-protection

or

yarn add react-native-capture-protection

iOS

cd ios
pod install

Enable Protection

import CaptureProtection from 'react-native-capture-protection';
await CaptureProtection.prevent();

Disable

await CaptureProtection.allow();

Detect Screenshots

import { useEffect } from 'react';
import CaptureProtection from 'react-native-capture-protection';
useEffect(() => {
 const subscription = CaptureProtection.addScreenshotListener(() => {
   console.log('Screenshot taken');
 });
 return () => subscription.remove();
}, []);

Detect Screen Recording

useEffect(() => {
  const subscription =
    CaptureProtection.addScreenRecordingListener((isRecording) => {
      console.log(isRecording);
    });

  return () => subscription.remove();
}, []);

 

Check Current Recording Status

const recording = await CaptureProtection.isScreenRecording();

Enable Only on Sensitive Screens

import { useFocusEffect } from '@react-navigation/native';
import { useCallback } from 'react';
import CaptureProtection from 'react-native-capture-protection';
useFocusEffect(
 useCallback(() => {
   CaptureProtection.prevent();
   return () => {
     CaptureProtection.allow();
   };
 }, [])
);

This protects only the current screen.

Platform Support

FeatureAndroidiOS
Prevent screenshots
Detect screenshots
Detect screen recording
Prevent screen recording✅ (FLAG_SECURE)
Recent apps preview protectionLimited (requires app-specific UI handling)

Notes

  • Android: prevent() uses FLAG_SECURE, which blocks screenshots, screen recording, and protects the app preview in the recent apps screen.
  • iOS: Apple does not allow apps to prevent screenshots. The library can only detect screenshots after they occur and notify you when screen recording is active.

Leave a comment

Your email address will not be published. Required fields are marked *

Your experience on this site will be improved by allowing cookies.