Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
@fingerprintjs/fingerprintjs-pro-react
Advanced tools
Fingerprint is a device intelligence platform offering 99.5% accurate visitor identification. Fingerprint Pro React SDK is an easy way to integrate Fingerprint Pro into your React application. It's also compatible with Next.js and Preact. See application demos in the examples folder.
[!NOTE] This package assumes you have a Fingerprint Pro subscription or trial, it is not compatible with the source-available FingerprintJS. See our documentation to learn more about the differences between Fingerprint Pro and FingerprintJS.
Using npm:
npm install @fingerprintjs/fingerprintjs-pro-react
Using yarn:
yarn add @fingerprintjs/fingerprintjs-pro-react
Using pnpm:
pnpm add @fingerprintjs/fingerprintjs-pro-react
In order to identify visitors, you'll need a Fingerprint Pro account (you can sign up for free). To get your API key and get started, see the Fingerprint Pro Quick Start Guide.
<FpjsProvider>
.apiKey
to your Fingerprint Public API Key.region
if you have chosen a non-global region during registration.endpoint
and scriptUrlPattern
if you are using one of our proxy integrations to increase accuracy and effectiveness of visitor identification.// src/index.js
import React from 'react'
import ReactDOM from 'react-dom/client'
import { FpjsProvider /*, FingerprintJSPro */ } from '@fingerprintjs/fingerprintjs-pro-react'
import App from './App'
const root = ReactDOM.createRoot(document.getElementById('app'))
root.render(
<FpjsProvider
loadOptions={{
apiKey: 'your-public-api-key',
// region: 'eu',
// endpoint: ['metrics.yourwebsite.com', FingerprintJSPro.defaultEndpoint],
// scriptUrlPattern: ['metrics.yourwebsite.com/agent-path', FingerprintJSPro.defaultScriptUrlPattern],
}}
>
<App />
</FpjsProvider>
)
useVisitorData()
hook in your components to identify visitors// src/App.js
import React from 'react'
import { useVisitorData } from '@fingerprintjs/fingerprintjs-pro-react'
function App() {
const { isLoading, error, data } = useVisitorData()
if (isLoading) {
return <div>Loading...</div>
}
if (error) {
return <div>An error occured: {error.message}</div>
}
if (data) {
// Perform some logic based on the visitor data
return (
<div>
Welcome {data.visitorFound ? 'back' : ''}, {data.visitorId}!
</div>
)
} else {
return null
}
}
export default App
The useVisitorData
hook also returns a getData
method you can use to make an API call on command.
// src/App.js
import React, { useState } from 'react'
import { useVisitorData } from '@fingerprintjs/fingerprintjs-pro-react'
function App() {
const { isLoading, error, getData } = useVisitorData({ tag: 'subscription-form' }, { immediate: false })
const [email, setEmail] = useState('')
if (isLoading) {
return <div>Loading...</div>
}
if (error) {
return <div>An error occurred: {error.message}</div>
}
return (
<div>
<form
onSubmit={(e) => {
e.preventDefault()
getData()
.then((data) => {
// Do something with the visitor data, for example,
// append visitor data to the form data to send to your server
console.log(data)
})
.catch((error) => {
// Handle error
})
}}
>
<label htmlFor='email'>Email:</label>
<input type='email' value={email} onChange={(e) => setEmail(e.currentTarget.value)} />
<button type='submit'>Subscribe</button>
</form>
</div>
)
}
export default App
The 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.
Associate 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:
// ...
function App() {
const {
isLoading,
error,
getData
} = useVisitorData({
linkedId: "user_1234",
tag: {
userAction: "login",
analyticsId: "UA-5555-1111-1"
}
});
// ...
Fingerprint 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.
cacheLocation
prop on <FpjsProvider>
to instead store results in memory
or localStorage
. Use none
to disable caching completely.cache
prop on <FpjsProvider>
to use your custom cache implementation instead. For more details, see Creating a custom cache
in the Fingerprint Pro SPA repository (a lower-level Fingerprint library used by this SDK).{ignoreCache: true}
to the getData()
function to ignore cached results for that specific API call.[!NOTE] If you use data from
extendedResult
, pay additional attention to your caching strategy. Some fields, for example,ip
orlastSeenAt
, might change over time for the same visitor. UsegetData({ ignoreCache: true })
to fetch the latest identification results.
The getData
function throws errors directly from the JS Agent without changing them. See JS Agent error handling for more details.
See the full generated API reference.
To ask questions or provide feedback, use 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 open-source FingerprintJS, consider creating an issue in the main FingerprintJS repository.
This project is licensed under the MIT license. See the LICENSE file for more info.
FAQs
FingerprintJS Pro React SDK
We found that @fingerprintjs/fingerprintjs-pro-react demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.