Overview
In this quickstart, you’ll add Fingerprint to a new React Native project and identify the user’s device. The example use case we’ll use for this quickstart is stopping new account fraud, where attackers create multiple fake accounts to abuse promotions, exploit systems, or evade bans. However, the steps you’ll follow apply to most use cases. By identifying the device behind each sign-up attempt, login, or transaction, you can flag and block suspicious users early. This guide focuses on the front-end mobile integration. You’ll install the Fingerprint React Native SDK and initialize the client to generate a request ID to send to your back end for analysis. To see how to implement fraud prevention with this ID, continue to one of our back-end quickstarts after completing this quickstart.Estimated time: < 10 minutes
Prerequisites
Before you begin, make sure you have the following:- Node.js (v16 or later) and npm installed
- React Native development environment set up (Expo not yet supported)
- Android 5.0 (API level 21+) or higher
- iOS 13+/tvOS 15+, Swift 5.7 or higher (stable releases)
- Xcode 15.0 or higher
- Your favorite code editor
- Basic knowledge of React Native and JavaScript
This quickstart only covers the front-end setup. You’ll need a back-end
server to receive and process the device
identification event to enable fraud detection. Check out one of our back-end
quickstarts after completing this
quickstart.
1. Create a Fingerprint account and get your API key
- Sign up for a free Fingerprint trial if you don’t already have an account.
- After signing in, go to the API keys page in the dashboard.
- Copy your public API key; you’ll need it to initialize the Fingerprint client agent.
2. Set up your project
To get started, create a new React Native project. If you already have a project you want to use, you can skip to the next section.- Create a new React Native project using the CLI:
Terminal
- Install the project dependencies:
Terminal
- Test that your project runs correctly, run:
Terminal
Terminal
Terminal
3. Install the Fingerprint SDK
To integrate Fingerprint into your React Native app, first add the SDK to your project.- Install the Fingerprint React Native SDK:
Terminal
- Install iOS dependencies using CocoaPods:
Terminal
- Add the Fingerprint Maven repository to your Android configuration. Open
android/settings.gradleand add the repository to thedependencyResolutionManagementblock:
android/settings.gradle
android/build.gradle instead:
android/build.gradle
4. Initialize the SDK
Now that the SDK is installed, you can import and initialize it in your app.- Open
App.tsxand replace the entire file with the following code to set up the Fingerprint provider and basic UI structure:
App.tsx
- Replace
<your-public-api-key>with your actual public API key from the Fingerprint dashboard. Note: For production, consider using React Native Config or environment variables to securely store your API key.
5. Create the account creation screen
Now you’ll create a simple account creation form that will trigger device identification when the user submits it.- Create a new file called
CreateAccountScreen.jsxin your project root with the following content:
CreateAccountScreen.tsx
6. Trigger visitor identification
The code you just added uses Fingerprint’suseVisitorData hook to identify the visitor when they submit the form. Let’s break down the key parts:
- Import the hook
CreateAccountScreen.tsx
- Initialize the hook
CreateAccountScreen.tsx
getData(): A function to trigger visitor identification on demandisLoading: A flag to monitor identification progresserror: Any errors that occur during identification
- Trigger identification on form submit
CreateAccountScreen.tsx
visitorId as well as a requestId. Instead of using the visitorId returned directly on the front end (which could be tampered with), you’ll send the requestId to your back end. This ID is unique to each identification event. Your server can then use the Fingerprint Events API to retrieve complete identification data, including the trusted visitor ID and other actionable insights like whether they are using a VPN or are a bot.
7. Run and test the app
- Start your development server and build your app:
Terminal
Terminal
Terminal
- In your app, enter a username and password, then tap Create Account.
- You should see an alert showing the request ID, and in your development console (Metro bundler terminal), you should see output similar to:
Output
- If you’re using a physical device, you can also use remote debugging tools like Flipper or React Native Debugger to view console logs.
Next steps
To use the identification data for fraud detection (like blocking repeat fake account creation attempts), you’ll need to send therequestId to your back end. From there, your server can call the Fingerprint Events API to retrieve the full visitor information and make decisions.
Check out these related resources: