{"id":19167142,"url":"https://github.com/fingerprintjs/fingerprintjs-pro-react","last_synced_at":"2025-04-13T00:42:46.197Z","repository":{"id":37787297,"uuid":"459904203","full_name":"fingerprintjs/fingerprintjs-pro-react","owner":"fingerprintjs","description":"Fingerprint Pro Wrapper for React Single Page Applications (SPA)","archived":false,"fork":false,"pushed_at":"2025-03-17T11:44:31.000Z","size":3339,"stargazers_count":60,"open_issues_count":1,"forks_count":11,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-04-13T00:42:35.606Z","etag":null,"topics":["device-identification","device-identifier","fingerprinting","fingerprintjs","fraud-detection","fraud-prevention","identification","integration","multi-account-detection","nextjs","react","single-page-app","single-page-application","spa","wrapper"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fingerprintjs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"contributing.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-02-16T07:54:02.000Z","updated_at":"2025-04-04T19:13:14.000Z","dependencies_parsed_at":"2023-10-05T12:51:10.804Z","dependency_job_id":"5b876b29-ba80-467c-8724-8adcca73572b","html_url":"https://github.com/fingerprintjs/fingerprintjs-pro-react","commit_stats":{"total_commits":198,"total_committers":18,"mean_commits":11.0,"dds":0.7575757575757576,"last_synced_commit":"512af6151c9934b8e6a5feefc926bd6810594f81"},"previous_names":[],"tags_count":38,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fingerprintjs%2Ffingerprintjs-pro-react","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fingerprintjs%2Ffingerprintjs-pro-react/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fingerprintjs%2Ffingerprintjs-pro-react/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fingerprintjs%2Ffingerprintjs-pro-react/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fingerprintjs","download_url":"https://codeload.github.com/fingerprintjs/fingerprintjs-pro-react/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248650417,"owners_count":21139672,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["device-identification","device-identifier","fingerprinting","fingerprintjs","fraud-detection","fraud-prevention","identification","integration","multi-account-detection","nextjs","react","single-page-app","single-page-application","spa","wrapper"],"created_at":"2024-11-09T09:35:57.850Z","updated_at":"2025-04-13T00:42:46.166Z","avatar_url":"https://github.com/fingerprintjs.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://fingerprint.com\"\u003e\n   \u003cpicture\u003e\n     \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://fingerprintjs.github.io/home/resources/logo_light.svg\" /\u003e\n     \u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://fingerprintjs.github.io/home/resources/logo_dark.svg\" /\u003e\n     \u003cimg src=\"https://fingerprintjs.github.io/home/resources/logo_dark.svg\" alt=\"Fingerprint logo\" width=\"312px\" /\u003e\n   \u003c/picture\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/fingerprintjs/fingerprintjs-pro-react/actions/workflows/release.yml\"\u003e\u003cimg src=\"https://github.com/fingerprintjs/fingerprintjs-pro-react/actions/workflows/release.yml/badge.svg\" alt=\"CI badge\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://fingerprintjs.github.io/fingerprintjs-pro-react/coverage/\"\u003e\u003cimg src=\"https://fingerprintjs.github.io/fingerprintjs-pro-react/coverage/badges.svg\" alt=\"coverage\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/@fingerprintjs/fingerprintjs-pro-react\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/@fingerprintjs/fingerprintjs-pro-react.svg\" alt=\"Current NPM version\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/@fingerprintjs/fingerprintjs-pro-react\"\u003e\u003cimg src=\"https://img.shields.io/npm/dm/@fingerprintjs/fingerprintjs-pro-react.svg\" alt=\"Monthly downloads from NPM\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://opensource.org/licenses/MIT\"\u003e\u003cimg src=\"https://img.shields.io/:license-mit-blue.svg\" alt=\"MIT license\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://discord.gg/39EpE2neBg\"\u003e\u003cimg src=\"https://img.shields.io/discord/852099967190433792?style=logo\u0026label=Discord\u0026logo=Discord\u0026logoColor=white\" alt=\"Discord server\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://fingerprintjs.github.io/fingerprintjs-pro-react/\"\u003e\u003cimg src=\"https://img.shields.io/badge/-Documentation-green\" alt=\"Discord server\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n# Fingerprint Pro React\n\nFingerprint is a device intelligence platform offering 99.5% accurate visitor identification. Fingerprint Pro React SDK is an easy way to integrate **[Fingerprint Pro](https://fingerprint.com/)** into your React application. It's also compatible with Next.js and Preact. See application demos in the [examples](https://github.com/fingerprintjs/fingerprintjs-pro-react/tree/main/examples) folder.\n\n## Table of contents\n\n\n- [Fingerprint Pro React](#fingerprint-pro-react)\n  - [Table of contents](#table-of-contents)\n  - [Requirements](#requirements)\n  - [Installation](#installation)\n  - [Getting started](#getting-started)\n    - [1. Wrap your application (or component) in `\u003cFpjsProvider\u003e`.](#1-wrap-your-application-or-component-in-fpjsprovider)\n    - [2. Use the `useVisitorData()` hook in your components to identify visitors](#2-use-the-usevisitordata-hook-in-your-components-to-identify-visitors)\n  - [Linking and tagging information](#linking-and-tagging-information)\n  - [Caching strategy](#caching-strategy)\n  - [Error handling](#error-handling)\n  - [API Reference](#api-reference)\n  - [Support and feedback](#support-and-feedback)\n  - [License](#license)\n\n## Requirements\n\n- React 18 or higher\n- For Preact users: Preact 10.3 or higher\n- For Next.js users: Next.js 13.1 or higher\n- For Typescript users: Typescript 4.8 or higher\n\n\u003e [!NOTE]\n\u003e This package assumes you have a Fingerprint Pro subscription or trial, it is not compatible with the [source-available FingerprintJS](https://github.com/fingerprintjs/fingerprintjs). See our documentation to learn more about the [differences between Fingerprint Pro and FingerprintJS](https://dev.fingerprint.com/docs/identification-vs-fingerprintjs).\n\n## Installation\n\nUsing [npm](https://npmjs.org):\n\n```sh\nnpm install @fingerprintjs/fingerprintjs-pro-react\n```\n\nUsing [yarn](https://yarnpkg.com):\n\n```sh\nyarn add @fingerprintjs/fingerprintjs-pro-react\n```\n\nUsing [pnpm](https://pnpm.js.org):\n\n```sh\npnpm add @fingerprintjs/fingerprintjs-pro-react\n```\n\n## Getting started\n\nIn order to identify visitors, you'll need a Fingerprint Pro account (you can [sign up for free](https://dashboard.fingerprint.com/signup/)).\nTo get your API key and get started, see the [Fingerprint Pro Quick Start Guide](https://dev.fingerprint.com/docs/quick-start-guide).\n\n### 1. Wrap your application (or component) in `\u003cFpjsProvider\u003e`.\n\n- Set `apiKey` to your Fingerprint [Public API Key](https://dashboard.fingerprint.com/api-keys).\n- Set `region` if you have chosen a non-global [region](https://dev.fingerprint.com/docs/regions) during registration.\n- Set `endpoint` and `scriptUrlPattern` if you are using [one of our proxy integrations to increase accuracy](https://dev.fingerprint.com/docs/protecting-the-javascript-agent-from-adblockers) and effectiveness of visitor identification.\n- You can use all the [load options](https://dev.fingerprint.com/reference/load-function#load-options) available in the JavaScript agent `load` function.\n\n```jsx\n// src/index.js\nimport React from 'react'\nimport ReactDOM from 'react-dom/client'\nimport {\n  FpjsProvider,\n  FingerprintJSPro,\n} from '@fingerprintjs/fingerprintjs-pro-react'\nimport App from './App'\n\nconst root = ReactDOM.createRoot(document.getElementById('app'))\n\nroot.render(\n  \u003cFpjsProvider\n    loadOptions={{\n      apiKey: 'your-public-api-key',\n      // region: 'eu',\n      endpoint: [\n        // 'metrics.yourwebsite.com',\n        FingerprintJSPro.defaultEndpoint,\n      ],\n      scriptUrlPattern: [\n        // 'https://metrics.yourwebsite.com/web/v\u003cversion\u003e/\u003capiKey\u003e/loader_v\u003cloaderVersion\u003e.js',\n        FingerprintJSPro.defaultScriptUrlPattern,\n      ],\n    }}\n  \u003e\n    \u003cApp /\u003e\n  \u003c/FpjsProvider\u003e\n)\n```\n\n### 2. Use the `useVisitorData()` hook in your components to identify visitors\n\n```jsx\n// src/App.js\nimport React from 'react'\nimport { useVisitorData } from '@fingerprintjs/fingerprintjs-pro-react'\n\nfunction App() {\n  const { isLoading, error, data } = useVisitorData()\n\n  if (isLoading) {\n    return \u003cdiv\u003eLoading...\u003c/div\u003e\n  }\n  if (error) {\n    return \u003cdiv\u003eAn error occured: {error.message}\u003c/div\u003e\n  }\n\n  if (data) {\n    // Perform some logic based on the visitor data\n    return (\n      \u003cdiv\u003e\n        Welcome {data.visitorFound ? 'back' : ''}, {data.visitorId}!\n      \u003c/div\u003e\n    )\n  } else {\n    return null\n  }\n}\n\nexport default App\n```\n\nThe `useVisitorData` hook also returns a `getData` method you can use to make an API call on command.\n\n- You can pass `{ ignoreCache: true }` to `useVisitorData` to force a fresh identification request.\n- You can pass `{ immediate: false }` to `useVisitorData` to disable automatic visitor identification on render.\n\nBoth `useVisitorData` and `getData` accept all the [get options](https://dev.fingerprint.com/reference/get-function#get-options) available in the JavaScript agent `get` function.\n\n```jsx\n// src/App.js\nimport React, { useState } from 'react'\nimport { useVisitorData } from '@fingerprintjs/fingerprintjs-pro-react'\n\nfunction App() {\n  const { isLoading, error, getData } = useVisitorData(\n    { ignoreCache: true },\n    { immediate: false }\n  )\n  const [email, setEmail] = useState('')\n\n  if (isLoading) {\n    return \u003cdiv\u003eLoading...\u003c/div\u003e\n  }\n  if (error) {\n    return \u003cdiv\u003eAn error occurred: {error.message}\u003c/div\u003e\n  }\n\n  return (\n    \u003cdiv\u003e\n      \u003cform\n        onSubmit={(e) =\u003e {\n          e.preventDefault()\n          getData()\n            .then((data) =\u003e {\n              // Do something with the visitor data, for example,\n              // append visitor data to the form data to send to your server\n              console.log(data)\n            })\n            .catch((error) =\u003e {\n              // Handle error\n            })\n        }}\n      \u003e\n        \u003clabel htmlFor='email'\u003eEmail:\u003c/label\u003e\n        \u003cinput\n          type='email'\n          value={email}\n          onChange={(e) =\u003e setEmail(e.currentTarget.value)}\n        /\u003e\n        \u003cbutton type='submit'\u003eSubscribe\u003c/button\u003e\n      \u003c/form\u003e\n    \u003c/div\u003e\n  )\n}\n\nexport default App\n```\n\n- See the full code example in the [examples folder](./examples/).\n- See our [Use cases](https://demo.fingerprint.com) page for [open-source](https://github.com/fingerprintjs/fingerprintjs-pro-use-cases) real-world examples of using Fingerprint to detect fraud and streamline user experiences.\n\n## Linking and tagging information\n\nThe `visitorId` provided by Fingerprint Identification is especially useful when combined with information you already know about your users, for example, account IDs, order IDs, etc. To learn more about various applications of the `linkedId` and `tag`, see [Linking and tagging information](https://dev.fingerprint.com/docs/tagging-information).\n\nAssociate the visitor ID with your data using the `linkedId` or `tag` parameter of the options object passed into the `useVisitorData()` hook or the `getData` function:\n\n```jsx\n// ...\nfunction App() {\n  const { isLoading, error, getData } = useVisitorData({\n    linkedId: 'user_1234',\n    tag: {\n      userAction: 'login',\n      analyticsId: 'UA-5555-1111-1',\n    },\n  })\n}\n// ...\n```\n\n## Caching strategy\n\nFingerprint Pro usage is billed per API call. To avoid unnecessary API calls, it is a good practice to cache identification results. By default, the SDK uses `sessionStorage` to cache results.\n\n- Specify the `cacheLocation` prop on `\u003cFpjsProvider\u003e` to instead store results in `memory` or `localStorage`. Use `none` to disable caching completely.\n- Specify the `cacheTimeInSeconds` prop on `\u003cFpjsProvider\u003e` to set the cache time in seconds. It cannot exceed 86400 seconds (24 hours).\n- Specify the `cache` prop on `\u003cFpjsProvider\u003e` to use your custom cache implementation instead. For more details, see [Creating a custom cache](https://github.com/fingerprintjs/fingerprintjs-pro-spa#creating-a-custom-cache)\n  in the Fingerprint Pro SPA repository (a lower-level Fingerprint library used by this SDK).\n- Pass `{ignoreCache: true}` to the `getData()` function to ignore cached results for that specific API call.\n\n\u003e [!NOTE]\n\u003e If you use data from [`extendedResult`](https://dev.fingerprint.com/reference/get-function#extendedresult), pay additional attention to your caching strategy.\n\u003e Some fields, for example, `ip` or `lastSeenAt`, might change over time for the same visitor. Use `getData({ ignoreCache: true })` to fetch the latest identification results.\n\n## Error handling\n\nThe `getData` function throws errors directly from the JS Agent without changing them. See [JS Agent error handling](https://dev.fingerprint.com/reference/error-handling) for more details.\n\n## API Reference\n\nSee the full [generated API reference](https://fingerprintjs.github.io/fingerprintjs-pro-react/).\n\n## Support and feedback\n\nTo ask questions or provide feedback, use [Issues](https://github.com/fingerprintjs/fingerprintjs-pro-react/issues). If you need private support, please email us at `oss-support@fingerprint.com`. If you'd like to have a similar React wrapper for the [source-availalbe FingerprintJS](https://github.com/fingerprintjs/fingerprintjs), consider creating an issue in the main [FingerprintJS repository](https://github.com/fingerprintjs/fingerprintjs/issues).\n\n## License\n\nThis project is licensed under the MIT license. See the [LICENSE](https://github.com/fingerprintjs/fingerprintjs-pro-react/blob/main/LICENSE) file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffingerprintjs%2Ffingerprintjs-pro-react","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffingerprintjs%2Ffingerprintjs-pro-react","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffingerprintjs%2Ffingerprintjs-pro-react/lists"}