npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@ivan.ng/react-native-screenshot-detector

v0.1.0

Published

Detect device screenshots (iOS & Android) and screen recording (iOS) in React Native.

Readme

react-native-screenshot-detector

Detect when the user takes a screenshot (iOS & Android) and when the screen is being recorded / captured (iOS only) in React Native — via a simple listener API.

Privacy-friendly: the library only tells you that a screenshot or capture happened. It never accesses or exposes the screenshot image.

Features

  • 📸 Screenshot detection on iOS and Android
  • 🔴 Screen recording / capture detection on iOS (start & stop)
  • 🧩 Built as a React Native Turbo Native Module (New Architecture)
  • 🔔 Simple subscription API with automatic cleanup
  • 🟦 Written in TypeScript with full type definitions

Platform support

| Capability | iOS | Android | | ----------------------------------- | ---------- | ----------------------- | | Screenshot detection | ✅ iOS 15+ | ✅ Android 14+ (API 34) | | Screen recording/capture detection | ✅ iOS 15+ | ❌ Not supported |

Android has no public API to detect that a third-party app is recording the screen, so recording detection is iOS only. On Android the recording APIs are safe no-ops (isScreenCaptureSupported is false).

Requirements

  • React Native 0.81+ with the New Architecture enabled (the default in 0.81)
  • iOS 15.0+
  • Android 14+ (API level 34) at runtime for screenshot detection

Installation

npm install @ivan.ng/react-native-screenshot-detector

or

yarn add @ivan.ng/react-native-screenshot-detector

iOS

cd ios && pod install

Android

No manual steps. The library declares the required android.permission.DETECT_SCREEN_CAPTURE permission and merges it into your app automatically. It is a normal (non-runtime) permission — the user is not prompted. Screenshot detection uses the official Activity.registerScreenCaptureCallback API, which only fires while your app is in the foreground.

Usage

import { useEffect } from 'react';
import { Alert } from 'react-native';
import {
  addScreenshotListener,
  addScreenCaptureListener,
  isScreenBeingCaptured,
  isScreenCaptureSupported,
} from '@ivan.ng/react-native-screenshot-detector';

function useScreenshotGuard() {
  useEffect(() => {
    const screenshotSub = addScreenshotListener(() => {
      Alert.alert('Screenshot detected', 'Please respect content privacy.');
    });

    // iOS only — never fires on Android.
    const captureSub = addScreenCaptureListener(({ isCapturing }) => {
      console.log('Screen capture is now', isCapturing ? 'ON' : 'OFF');
    });

    return () => {
      screenshotSub.remove();
      captureSub.remove();
    };
  }, []);
}

// One-off query (iOS reflects UIScreen.isCaptured; Android resolves false)
const capturing = await isScreenBeingCaptured();

// Feature-detect at runtime
if (isScreenCaptureSupported) {
  // safe to rely on capture events
}

API

addScreenshotListener(listener: () => void): Subscription

Calls listener whenever the user takes a screenshot (iOS & Android). Returns a subscription — call .remove() to stop listening.

addScreenCaptureListener(listener: (event: { isCapturing: boolean }) => void): Subscription

Calls listener when screen recording/capture starts or stops. iOS only (never fires on Android). Returns a subscription with .remove().

isScreenBeingCaptured(): Promise<boolean>

Resolves whether the screen is currently being captured. Reflects UIScreen.isCaptured on iOS; resolves false on Android.

isScreenCaptureSupported: boolean

true on iOS, false on Android.

How it works

  • iOS: observes UIApplication.userDidTakeScreenshotNotification for screenshots and UIScreen.capturedDidChangeNotification / UIScreen.isCaptured for recording, mirroring, and AirPlay.
  • Android: registers an Activity.ScreenCaptureCallback via registerScreenCaptureCallback (API 34+), tied to your activity's lifecycle.

Disclaimer

This library is provided "as is" under the MIT License, without warranty of any kind — you use it at your own risk. You are solely responsible for ensuring your use of screenshot and screen-capture detection complies with all applicable laws, regulations, app-store policies, and privacy requirements. The author accepts no liability for any loss, damage, data leak, hack, or legal consequence arising from its use. By installing or using this library, you agree to accept that risk yourself.

Acceptable use. You agree not to use this library for any unlawful purpose, or in any manner that infringes the privacy, intellectual-property, or other rights of any person. You are solely responsible for how you integrate and use it.

Indemnification. To the fullest extent permitted by law, you agree to indemnify and hold harmless the author from any claims, damages, liabilities, losses, or expenses (including legal fees) arising out of or related to your use of this library or your violation of any law or third-party right.

License

MIT © 2026 ivan-ng-ivan


Made with create-react-native-library