React Native

Using the FingerprintJS Pro React Native library

FingerprintJS Pro React Native is an official open-source library for projects written in React Native for iOS and Android platforms. This library allows developers to use Fingerprint Pro capabilities in the React Native context. All Fingerprint Pro agent capabilities are fully supported.

Example Use Case

  1. Add @fingerprintjs/fingerprintjs-pro-react-native as a dependency to your application via npm or yarn.
npm install @fingerprintjs/fingerprintjs-pro-react-native --save
yarn add @fingerprintjs/fingerprintjs-pro-react-native
  1. Wrap your application (or component) in FingerprintJsProProvider. You can specify multiple configuration options.
// src/index.js
import React from 'react';
import { AppRegistry } from 'react-native';
import { FingerprintJsProProvider } from '@fingerprintjs/fingerprintjs-pro-react-native';
import App from './App';

AppRegistry.registerComponent(
  'AppName',
  <FingerprintJsProProvider
      apiKey="fingerprintjs-pro-public-api-key"
  >
    <App />
  </FingerprintJsProProvider>
);
  1. Use the useVisitorData hook in your components to perform visitor identification and get the data.
// src/App.js
import React, { useEffect } from 'react';
import { useVisitorData } from '@fingerprintjs/fingerprintjs-pro-react-native';

function App() {
  const {
    isLoading,
    error,
    data,
    getData,
  } = useVisitorData();

  useEffect(() => {
    getData();
  }, []);

  if (isLoading) {
    return <div>Loading...</div>;
  }
  if (error) {
    return <div>An error occured: {error.message}</div>;
  }

  if (!data) {
   return null
    }
  
  // perform some logic based on the visitor data
  return (
    <div>
      Visitor id is {data.visitorId}
    </div>
  );
}

export default App;

Documentation

You can find the full documentation in the official GitHub repository. The repository also contains an example app demonstrating usage of the library.

Limitations

  • FingerprintJS Pro request filtering is not supported right now. Allowed and forbidden origins cannot be used.
  • Using inside Expo environment is not supported right now.