Web Analytics
Skip to main content

Installation

React Native CLI (Bare Workflow)

For standard React Native projects created with React Native CLI:

npm install react-native-screenguard --save

After installation, continue to Linking for iOS pod installation.


Expo Projects

Development Build Required

React Native ScreenGuard uses native code and cannot run in Expo Go. You must use a development build.

Step 1: Install the package

npx expo install react-native-screenguard

Step 2: Generate native directories

Run Prebuild to generate the native android and ios directories:

npx expo prebuild --clean

This command creates native project files based on your app.json / app.config.js configuration.

Step 3: Build and run

For local development:

# iOS
npx expo run:ios

# Android
npx expo run:android

Or build using EAS Build:

eas build --platform all
Cleaning Native Directories

If you encounter issues after updating the library, try running:

npx expo prebuild --clean

This will regenerate native directories and ensure all native code is properly linked.

Why can't I use Expo Go?

Expo Go is a pre-built app that contains a limited set of native modules. Since React Native ScreenGuard requires custom native code for screenshot blocking, it cannot be included in Expo Go.

A development build is essentially your own custom version of Expo Go that includes all the native modules your project needs.

Further Reading