A comprehensive React Native wrapper for Sift iOS and Android SDKs, enabling fraud prevention and digital trust & safety in your mobile applications.
Sift is the leader in Digital Trust & Safety, empowering organizations of all sizes to unlock new revenue without risk using machine learning. This React Native SDK provides a unified interface to integrate Sift's fraud prevention capabilities across both iOS and Android platforms.
This guide will help you set up and run the sift-react-native project from scratch, including the example app.
Before you begin, ensure you have the following installed:
- Node.js 20.19.0+ (use nvm or check
.nvmrcfile) - Yarn 3.6.1+ (will be installed automatically via Corepack)
- React Native development environment:
- For iOS: Xcode 14+, CocoaPods, and iOS Simulator
- For Android: Android Studio, Android SDK, and Android Emulator
- Watchman (recommended for file watching)
- Git
git clone https://github.com/SiftScience/sift-react-native.git
cd sift-react-nativeThe project uses Yarn 3.6.1 with workspaces. Dependencies will be installed automatically:
# Enable Corepack (if not already enabled)
corepack enable
# Install all dependencies (root + example app)
yarn installThis will:
- Install root project dependencies
- Install example app dependencies
- Link the workspace packages
Build the TypeScript source code and generate type definitions:
# Build the library
yarn prepare
# or
npx react-native-builder-bob buildThis creates the lib/ directory with compiled JavaScript and TypeScript definitions.
cd example/ios
bundle install # Install Ruby dependencies (first time only)
bundle exec pod install
cd ../..Make sure you have an iOS Simulator available. You can list available simulators:
xcrun simctl list devicesEnsure your Android SDK is properly configured. The example app will use the SDK path from your environment or ANDROID_HOME variable.
If needed, create example/android/local.properties:
sdk.dir=/path/to/your/android/sdkReplace /path/to/your/android/sdk with your actual Android SDK path (typically ~/Library/Android/sdk on macOS or %LOCALAPPDATA%\Android\Sdk on Windows).
Start an Android emulator or connect a physical device:
# List available emulators
emulator -list-avds
# Start an emulator (replace with your AVD name)
emulator -avd YourAVDNameIn the root directory, start the Metro bundler:
# From root directory
yarn start:example
# or
cd example && yarn startKeep this terminal running.
In a new terminal:
# From root directory
yarn ios:example
# or
cd example && yarn iosIn a new terminal:
# From root directory
yarn android:example
# or
cd example && yarn androidOnce the app launches:
-
The example app should display a form with fields for:
- Account ID
- Beacon Key
- User ID
- Server URL Format
-
Fill in your Sift credentials and tap "UPLOAD" to test the integration.
# Run all tests
yarn test
# Run tests in watch mode
yarn test --watch# Lint the codebase
yarn lint# Type check TypeScript files
yarn typecheck# Clean all build artifacts
yarn cleanIf you encounter module resolution errors:
# Clear Metro cache
yarn start:example --reset-cache# Clean and reinstall pods
cd example/ios
rm -rf Pods Podfile.lock
bundle exec pod install
cd ../..# Clean Android build
cd example/android
./gradlew clean
cd ../..If you encounter workspace linking issues:
# Remove node_modules and reinstall
rm -rf node_modules example/node_modules
yarn installsift-react-native/
├── src/ # TypeScript source code
├── lib/ # Compiled output (generated)
├── ios/ # iOS native implementation
├── android/ # Android native implementation
├── example/ # Example React Native app
│ ├── src/ # Example app source
│ ├── ios/ # iOS example app
│ └── android/ # Android example app
├── package.json # Root package configuration
└── yarn.lock # Dependency lock file
import React, { useEffect } from 'react';
import SiftReactNative from 'sift-react-native';
const App = () => {
useEffect(() => {
// Initialize Sift when app starts
SiftReactNative.setSiftConfig(
'your-account-id',
'your-beacon-key',
false, // Allow location collection
'https://api3.siftscience.com/v3/accounts/%s/mobile_events'
);
}, []);
const handleUserLogin = (userId: string) => {
SiftReactNative.setUserId(userId);
SiftReactNative.upload();
};
const handleUserLogout = () => {
SiftReactNative.unsetUserId();
};
return (
// Your app components
);
};MIT License - see LICENSE file for details.
For technical support and questions:
- Documentation: Sift Developer Docs
- Issues: GitHub Issues
- Email: support@sift.com
Made with ❤️ by the Sift team