Utility for generating user fingerprints with one function
npm install react-fingerprintUtility for generating user fingerprints with one function.
``ts
import { getFingerprint, getRawFingerprint } from "react-fingerprint";
// const { getFingerprint, getRawFingerprint } = require("react-fingerprint") (cjs version)
const asyncFunc = async () => {
let fingerprint = await getFingerprint() // fingerprint id
let rawData = await getRawFingerprint() // raw data that is used to make the fingerprint
}
`
This package relies entirely on browser APIs, so if you are using it with an SSR framework (example being Remix) then find a way to run it only client-side
To run code client-side in Remix, you use the React useEffect function.
`js
import { getFingerprint } from "react-fingerprint"
import React, {useEffect} from "react"
export default function view() {
useEffect(() => {
(async () => { // as react-fingerprint returns promises, you will need to either wrap it in an async func or use .then()
let fingerprint = await getFingerprint()
})
})
return (