
Research
2025 Report: Destructive Malware in Open Source Packages
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.
react-native-screenshot-aware
Advanced tools
React Native module for real-time screenshot detection on Android and iOS
yarn add react-native-screenshot-aware
or
npm install react-native-screenshot-aware
DETECT_SCREEN_CAPTURE permission introduced in Android 14For Expo projects, you can use the Expo plugin in app.json
"plugins": [
"react-native-screenshot-aware"
],
or add the permission manually to your app.json:
"android": {
"permissions": ["android.permission.DETECT_SCREEN_CAPTURE"]
}
To use the screenshot detection feature on Android, you need to add the following permission to your AndroidManifest.xml file:
<uses-permission android:name="android.permission.DETECT_SCREEN_CAPTURE" />
Note: Callbacks will never be triggered on devices running Android versions below 14. This is due to the reliance on the new
DETECT_SCREEN_CAPTUREpermission and APIs introduced in Android 14, which are not available in earlier versions.
Note: The decision to support only Android 14+ is based on the introduction of new, dedicated screenshot detection APIs. These APIs offer improved performance and respect user privacy better than previous methods. For more details, see the Android 14 screenshot detection documentation.
useScreenshotAware(callback)This hook allows you to detect when a screenshot is taken on the device. It takes a callback function as an argument, which will be executed whenever a screenshot event is detected.
callback (function): A function to be called when a screenshot is detected. This function does not take any arguments.import { useScreenshotAware } from 'react-native-screenshot-aware';
useScreenshotAware(() => {
console.log('A screenshot was taken!');
});
addListener(callback)This function allows you to add a listener for the screenshot event. It takes a callback function as an argument, which will be executed whenever a screenshot event is detected.
callback (function): A function to be called when a screenshot is detected. This function does not take any arguments.import ScreenshotAware from 'react-native-screenshot-aware';
useEffect(() => {
const listener = ScreenshotAware.addListener(() => {
console.log('A screenshot was taken!');
});
return () => {
listener.remove();
}
}, [])
removeAllListeners()This function allows you to remove all listeners for the screenshot event.
import ScreenshotAware from 'react-native-screenshot-aware';
function removeScreenshotListeners() {
ScreenshotAware.removeAllListeners();
}
jest.mock('react-native-screenshot-aware', () => ({
useScreenshotAware: jest.fn(),
addListener: jest.fn().mockReturnValue({
remove: jest.fn(),
}),
removeAllListeners: jest.fn(),
}));
We welcome contributions! Please see our Contributing Guide for more details.
This project is licensed under the MIT License - see the LICENSE file for details.
If you like this project, please consider supporting it by giving it a ⭐️ on GitHub!
FAQs
React Native module for real-time screenshot detection on Android and iOS
The npm package react-native-screenshot-aware receives a total of 3,663 weekly downloads. As such, react-native-screenshot-aware popularity was classified as popular.
We found that react-native-screenshot-aware demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.

Security News
Socket CTO Ahmad Nassri shares practical AI coding techniques, tools, and team workflows, plus what still feels noisy and why shipping remains human-led.

Research
/Security News
A five-month operation turned 27 npm packages into durable hosting for browser-run lures that mimic document-sharing portals and Microsoft sign-in, targeting 25 organizations across manufacturing, industrial automation, plastics, and healthcare for credential theft.