UNPKG

fingerprintjs-pro

Version:

A React library for integrating FingerprintJS Pro to identify users with high accuracy.

83 lines (65 loc) 2.19 kB
# FingerprintJS Pro - Usage Guide ## Introduction This guide explains how to use `fingerprintjs-pro` to obtain a unique token with a single function call. Note that `fingerprintjs-pro` requires an API key and is restricted to specific domains. ## Features - **Accurate Device Identification**: Identify users across browsers and devices. - **Enhanced Security**: Prevent fraud and unauthorized access. - **Easy Integration**: Simple API for seamless integration. - **Fast & Reliable**: Generates fingerprints in milliseconds. - **React Compatible**: Works in React applications. - **Unique Browser ID**: Generates a unique ID per browser instance. ## Installation Install `fingerprintjs-pro` using npm or yarn: ```sh npm install fingerprintjs-pro ``` or ```sh yarn add fingerprintjs-pro ``` ## Importing the Function Import `getFingerprint` in your JavaScript/TypeScript file: ```js import { getFingerprint } from 'fingerprintjs-pro'; ``` ## Getting the Token Call `getFingerprint()` with your API key: ```js async function fetchToken(apiKey) { try { const response = await getFingerprint(apiKey); console.log('API Response:', response); } catch (error) { console.error('Error fetching fingerprint:', error); } } fetchToken('your-api-key-here'); ``` ## API Response Format ```json { "status": 200, "token": "e3fee4271f1c4f1552a2cfe15ac470162f7b7d8b97b65a6f7495cc65cff103a7" } ``` ### Response Fields - `status`: HTTP status code (200 means success) - `token`: Unique token ## Error Handling Handle potential errors like network issues or API failures: ```js async function fetchToken(apiKey) { try { const response = await getFingerprint(apiKey); if (response.status === 200) { console.log('Token:', response.token); } else { console.warn('Unexpected response:', response); } } catch (error) { console.error('Failed to fetch token:', error); } } ``` ## Conclusion Use `fingerprintjs-pro` to retrieve unique tokens securely. Ensure error handling and domain access validation.