What is @fingerprintjs/fingerprintjs?
@fingerprintjs/fingerprintjs is a JavaScript library that provides a way to uniquely identify users based on their browser and device characteristics. It is commonly used for fraud prevention, user authentication, and personalization.
What are @fingerprintjs/fingerprintjs's main functionalities?
Generate a Visitor Identifier
This feature allows you to generate a unique identifier for a visitor based on their browser and device characteristics. The code sample demonstrates how to load the FingerprintJS library, generate a visitor identifier, and log it to the console.
const FingerprintJS = require('@fingerprintjs/fingerprintjs');
FingerprintJS.load().then(fp => {
fp.get().then(result => {
const visitorId = result.visitorId;
console.log(visitorId);
});
});
Get Detailed Visitor Data
This feature provides detailed information about the visitor's browser and device characteristics. The code sample shows how to access and log the detailed components of the visitor's fingerprint.
const FingerprintJS = require('@fingerprintjs/fingerprintjs');
FingerprintJS.load().then(fp => {
fp.get().then(result => {
const components = result.components;
console.log(components);
});
});
Other packages similar to @fingerprintjs/fingerprintjs
clientjs
ClientJS is a JavaScript library for generating a client-side fingerprint based on browser and device characteristics. It offers similar functionality to @fingerprintjs/fingerprintjs but may not be as comprehensive in terms of the data it collects and analyzes.
fingerprintjs2
FingerprintJS2 is an older version of the FingerprintJS library. It provides similar functionality for generating unique visitor identifiers but lacks some of the newer features and improvements found in @fingerprintjs/fingerprintjs.
ua-parser-js
UA-Parser-JS is a JavaScript library for parsing user-agent strings to identify browser, engine, OS, CPU, and device type/model. While it does not generate a unique visitor identifier, it provides detailed information about the user's environment, which can be used in conjunction with other libraries for fingerprinting.
Makes a website visitor identifier from a browser fingerprint.
Unlike cookies and local storage, fingerprint stays the same in incognito/private mode and even when browser data is purged.
Quick start
Install from CDN
<script>
function onFingerprintJSLoad(fpAgent) {
fpAgent.get().then(result => {
const visitorId = result.visitorId;
console.log(visitorId);
});
}
</script>
<script
async src="https://cdn.jsdelivr.net/npm/@fingerprintjs/fingerprintjs@3/dist/fp.min.js"
onload="FingerprintJS.load().then(onFingerprintJSLoad)"
></script>
We recommend to upload the JS script
to your server because AdBlock and other browser extensions can block the public script URL.
Alternatively you can install from NPM to use with Webpack/Rollup/Browserify
npm i @fingerprintjs/fingerprintjs
yarn add @fingerprintjs/fingerprintjs
import FingerprintJS from '@fingerprintjs/fingerprintjs';
(async () => {
const fpAgent = await FingerprintJS.load();
const result = await fpAgent.get();
const visitorId = result.visitorId;
console.log(visitorId);
})();
📕 Full documentation
Upgrade to Pro version to get 99.5% identification accuracy
| Open Source version | Pro version |
---|
Identification accuracy | 60% | 99.5% |
Bot detection | ❌ | ✅ |
Incognito / Private mode detection | ❌ | ✅ |
Geolocation | ❌ | ✅ |
Security | ❌ | ✅ |
Server API | ❌ | ✅ |
Webhooks | ❌ | ✅ |
Pro result example:
{
"requestId": "HFMlljrzKEiZmhUNDx7Z",
"visitorId": "kHqPGWS1Mj18sZFsP8Wl",
"visitorFound": true,
"incognito": false,
"bot": { "probability": 0.96 },
"browserName": "Chrome",
"browserVersion": "85.0.4183",
"os": "Mac OS X",
"osVersion": "10.15.6",
"device": "Other",
"ip": "192.65.67.131",
"ipLocation": {
"accuracyRadius": 100,
"latitude": 37.409657,
"longitude": -121.965467
}
}
🍿 Live demo
⏱ How to upgrade from Open Source to Pro in 30 seconds
📕 FingerprintJS Pro documentation
Open-source version reference
Installation
The library is shipped in various formats:
- Global variable
<script>
function initFingerprintJS() {
}
</script>
<script
async
src="https://cdn.jsdelivr.net/npm/@fingerprintjs/fingerprintjs@3/dist/fp.min.js"
onload="initFingerprintJS()"
></script>
- UMD
require(['https://cdn.jsdelivr.net/npm/@fingerprintjs/fingerprintjs@3/dist/fp.umd.min.js'], (FingerprintJS) => {});
- ECMAScript module
import FingerprintJS from '@fingerprintjs/fingerprintjs';
- CommonJS
const FingerprintJS = require('@fingerprintjs/fingerprintjs');
API
-
FingerprintJS.load({ delayFallback?: number }): Promise<Agent>
Builds an instance of Agent and waits a delay required for a proper operation.
delayFallback
is an optional parameter that sets duration (milliseconds) of the fallback for browsers that don't support requestIdleCallback;
it has a good default value which we don't recommend to change.
-
agent.get({ debug?: boolean }): Promise<{ visitorId: string, components: {/* ... */} }>
Gets the visitor identifier.
debug: true
prints debug messages to the console.
visitorId
is the visitor identifier.
components
is a dictionary of components that have formed the identifier;
each value is an object like { value: any, duration: number }
in case of success
and { error: object, duration: number }
in case of an unexpected error during getting the component.
-
FingerprintJS.hashComponents(components: object): string
Converts a dictionary of components (described above) into a short hash string a.k.a. a visitor identifier.
Designed for extending the library with your own components.
-
FingerprintJS.componentsToDebugString(components: object): string
Converts a dictionary of components (described above) into human-friendly format.
Migrating from v2
Version policy
The library doesn't guarantee the same visitor identifier between versions,
but will try to keep them the same as much as possible.
The documented JS API follows Semantic Versioning.
Use undocumented features at your own risk.
Browser support
npx browserslist "> 1% in us"
Contribution
See the contribution guidelines to learn how to start a playground, test and build.