Migration guide
Follow these steps to migrate from@fingerprintjs/fingerprintjs-pro-spa to the v4 JavaScript agent.
1. Update dependencies
Remove the SPA library and install the v4 agent:2. Update imports and initialization
The v4 agent usesFingerprint.start() instead of creating a FpjsClient instance and calling init().
SPA library to v4 agent
3. Update identification calls
ReplacegetVisitorData() with get().
getVisitorData to get
The v4 agent no longer supports
extendedResult. Extended data like IP address and geolocation should be retrieved server-side using the Server API or Sealed Client Results.4. Update cache configuration
The cache options have been renamed:| SPA library | v4 agent |
|---|---|
cacheLocation: 'sessionStorage' | cache: { storage: 'sessionStorage', ... } |
cacheLocation: 'localStorage' | cache: { storage: 'localStorage', ... } |
cacheLocation: 'memory' | cache: { storage: 'agent', ... } |
cacheLocation: 'nocache' | Omit the cache option entirely |
cacheTimeInSeconds: 3600 | cache: { duration: 3600, ... } or cache: { duration: 'optimize-cost', ... } |
'optimize-cost'— caches for 1 hour'aggressive'— caches for 12 hours (not recommended for fraud prevention)
5. Check for cached results
ThecacheHit property is now cache_hit in the response:
cacheHit to cache_hit