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

react-native-device-shield

v0.3.0

Published

Screen security & anti-fraud suite for React Native — jailbreak/root, emulator and screen recording detection via useDeviceSecurity()

Readme

react-native-device-shield

Screen security and device integrity for React Native — jailbreak/root detection, emulator detection, screen-recording monitoring, and screenshot blocking via useDeviceSecurity().

Built for fintech, e-commerce, and healthcare apps that need layered client-side defenses (HIPAA / KVKK oriented workflows).

Features

  • Jailbreak / root detection — heuristic checks on iOS and Android
  • Emulator / simulator detection — including common device-farm images
  • Screen recording detection — live events when capture starts or stops
  • Screenshot protection — Android FLAG_SECURE; iOS secure-layer blanking
  • Privacy mode — react when recording or a screenshot attempt is detected
  • TurboModule — New Architecture ready

Installation

npm install react-native-device-shield
# or
yarn add react-native-device-shield

iOS:

cd ios && pod install

Requires the New Architecture (TurboModule). React Native 0.76+ is recommended.

Quick start

import { useDeviceSecurity } from 'react-native-device-shield';

export function SecureScreen() {
  const { isCompromised, isScreenRecording, isSecureScreenEnabled } =
    useDeviceSecurity({
      preventScreenCapture: true, // Android FLAG_SECURE → captures blanked
      onPrivacyModeChange: ({ active, reason }) => {
        // Capture detected — swap sensitive UI if you want
      },
    });

  // Sensitive content is blanked by the OS when capture is blocked.
  return null;
}

Optionally wrap screens with <PrivacyShield /> and renderOverlay to show a custom warning UI to the user. Screenshots and recordings still stay black when secure mode is on.

iOS screenshot note

iOS does not offer a public API as strong as Android FLAG_SECURE. This library blanks content via a secure UITextField container. It often does not work in the Simulator — test on a real device.

API

useDeviceSecurity(options?)

| Field | Type | Description | |-------|------|-------------| | isJailbroken | boolean | iOS jailbreak signals | | isRooted | boolean | Android root signals (mirrors jailbreak on iOS) | | isEmulator | boolean | Emulator / Simulator / common device-farm images | | isScreenRecording | boolean | Screen recording / capture active | | isSecureScreenEnabled | boolean | Native screenshot blocking is on | | isPrivacyMode | boolean | Privacy mode after recording or screenshot | | isCompromised | boolean | isJailbroken \|\| isRooted \|\| isEmulator | | platform | 'ios' \| 'android' \| 'unknown' | Current platform | | isLoading | boolean | Initial native read in progress | | privacyReason | PrivacyModeReason \| null | Why privacy mode is active | | refresh() | () => void | Re-run checks immediately | | enableSecureScreen() | () => void | Enable screenshot / recording blocking | | disableSecureScreen() | () => void | Disable blocking | | exitPrivacyMode() | () => void | Leave privacy mode (ignored while recording) |

Options

| Option | Default | Description | |--------|---------|-------------| | preventScreenCapture | true | Android FLAG_SECURE, iOS secure layer | | nativePrivacyOverlay | false | Native black cover; keep off for custom UI. iOS only — Android already blanks via FLAG_SECURE, so this flag is a no-op there | | onPrivacyModeChange | — | Callback when privacy mode toggles | | pollIntervalMs | 3000 | How often to re-check static signals | | lazy | false | Defer first read until refresh() |

Note: preventScreenCapture is read on every render — flipping it from true to false at runtime calls disableSecureScreen() for you, same as flipping it back on calls enableSecureScreen().

<PrivacyShield /> (optional)

Shows a custom overlay to the person using the device when capture is detected. Captured output remains blanked by FLAG_SECURE / the iOS secure layer.

import { PrivacyShield } from 'react-native-device-shield';

<PrivacyShield
  preventScreenCapture
  renderOverlay={({ reason, exitPrivacyMode }) => (
    <MySafeScreen reason={reason} onContinue={exitPrivacyMode} />
  )}
>
  <SensitiveScreen />
</PrivacyShield>

<PrivacyShield /> doesn't do the blocking itself — it just calls useDeviceSecurity() internally and adds an overlay slot on top. useDeviceSecurity() alone (no wrapper needed) already enables FLAG_SECURE / the iOS secure layer by default; wrap with <PrivacyShield> only when you want a custom warning UI or the usePrivacyShield() context below.

Use usePrivacyShield() inside children to read the same security state from context (throws if called outside a <PrivacyShield>).

Pass hideContentInPrivacyMode to unmount children while privacy mode is active, instead of just layering the overlay on top:

<PrivacyShield hideContentInPrivacyMode renderOverlay={() => <BlockedScreen />}>
  <SensitiveScreen />
</PrivacyShield>

Imperative helpers

import {
  enableSecureScreen,
  getSecurityStatus,
  isEmulator,
  isJailbroken,
  isRooted,
  isScreenRecording,
} from 'react-native-device-shield';

enableSecureScreen();
const status = getSecurityStatus();

Also available: disableSecureScreen, isSecureScreenEnabled, setNativePrivacyOverlayEnabled, subscribeScreenRecording, subscribeScreenshotDetected, isNativeModuleAvailable() (check before calling native APIs directly, e.g. to detect Expo Go).

Platform notes

  • Android: FLAG_SECURE blanks screenshots and recordings; API 34+ uses ScreenCaptureCallback to detect attempts. Below API 34, capture is still blocked but no onScreenshotDetected event fires. isScreenRecording is a heuristic (looks for secondary displays named like "screen"/"record"/"capture"/"cast"/"mirror") — it can false-positive on things like Chromecast and miss recorders that don't match those names
  • iOS: UIScreen.isCaptured, screenshot notifications, and a secure text-field layer. Apple gives no public API to block the screenshot action itself — onScreenshotDetected fires after the OS already took it, and prevented just means the captured frame was blanked by the secure layer. The secure layer relies on an undocumented UITextField internal-view trick, so treat it as best-effort, not guaranteed across iOS versions
  • No single signal is 100% reliable — design defense in depth

Example app

yarn
yarn example ios
# or
yarn example android

License

MIT