Skip to main content

Overview

In this quickstart, you’ll add Fingerprint to a new Vue 3 project and identify the user’s device. The example use case in this quickstart is stopping new account fraud, where attackers create multiple fake accounts to abuse promotions, exploit systems, or evade bans. However, the steps you’ll follow apply to most use cases. By identifying the device behind each sign-up attempt, login, or transaction, you can flag and block suspicious users early. This guide focuses on the frontend integration. You’ll install the Fingerprint Vue SDK and initialize the JavaScript agent to generate an event ID to send to your backend for analysis. To see how to implement fraud prevention with this ID, continue to one of the backend quickstarts after completing this quickstart.
Estimated time: < 10 minutes

Prerequisites

Before you begin, make sure you have the following:
  • Node.js (v20 or later) and npm installed
  • Your favorite code editor
  • Basic knowledge of Vue 3 and JavaScript
This quickstart only covers the frontend setup. You’ll need a backend server to receive and process the device identification event to enable fraud detection. Check out one of the backend quickstarts after completing this quickstart.

1. Create a Fingerprint account and get your API key

  1. Sign up for a free Fingerprint trial if you don’t already have an account.
  2. After signing in, go to the API keys page in the dashboard.
  3. Copy your public API key; you’ll need it to initialize the JavaScript agent.

2. Set up your project

To get started, scaffold a new Vue app. If you already have a project you want to use, you can skip to the next section.
  1. Create a new Vite project with the Vue template:
Terminal
  1. Open the fingerprint-vue-quickstart folder in your code editor and you’re ready to go! To run your project, run:
Terminal
  1. In your browser, go to http://localhost:5173 (Vite’s default), and you should see the Vite welcome page.

3. Set up your account creation form

  1. Before adding Fingerprint, create a new component at src/components/CreateAccountForm.vue with the following:
src/components/CreateAccountForm.vue
  1. Import and add the component to your main view in src/App.vue:
src/App.vue

4. Install and initialize the JavaScript agent

  1. To integrate Fingerprint into your Vue app, first add the Fingerprint Vue SDK via npm:
Terminal
Note: This quickstart is written for version 2.x of the Fingerprint Vue SDK
  1. Now that the Vue SDK is installed, import and initialize it in your app’s entry point. Open src/main.js and import the Fingerprint plugin:
src/main.js
  1. Before mounting, initialize the plugin:
src/main.js
  1. Replace PUBLIC_API_KEY with your public API key from the Fingerprint dashboard.
Note: For production, consider using Vite Env Variables to configure the key.

5. Trigger visitor identification

Now that the JavaScript agent is initialized, you can identify the visitor only when needed. In this case, that’s when the user taps the Create Account button. When making the visitor identification request, you will receive a visitor ID as well as an event ID. Instead of using the visitor ID returned directly on the frontend (which could be tampered with), you’ll send the event ID to your backend. This ID is unique to each identification event. Your server can then use the Fingerprint Events API to retrieve complete identification data, including the trusted visitor ID and other actionable insights like whether they are using a VPN or are a bot.
  1. Within the empty script tags in CreateAccountForm.vue, import Vue’s ref and declare username and password as reactive variables to track your form inputs. Also import the Fingerprint useVisitorData hook:
src/components/CreateAccountForm.vue
  1. Initialize useVisitorData and access the returned values you’ll need:
src/components/CreateAccountForm.vue
This gives you:
  • getData(): A function to trigger visitor identification on demand.
  • isLoading: A flag to monitor visitor identification progress.
By setting immediate to false you’re triggering device identification only when needed with the getData() method. Check the Vue SDK reference for available useVisitorData options.
  1. Define the submit handler to trigger identification when the user clicks Create Account:
In this function:
  • getData() is being called and Fingerprint is analyzing the visitor’s browser; the result includes visitor_id and event_id.
  • You can send the event_id to your backend along with the username and password for your fraud detection logic.

6. Test the app

  1. If your dev server isn’t already running, start it with:
Terminal
  1. In your browser, go to http://localhost:5173 (Vite’s default).
  2. If you have any ad blockers, turn them off for localhost. View the documentation to learn how to protect your Fingerprint implementation from ad blockers in production.
  3. Enter a username and password, then click Create Account.
  4. Open the developer console in your browser and you should see the visitor_id and event_id in the output:
Output

Next steps

To use the identification data for fraud detection (like blocking repeat fake account creation attempts), you’ll need to send the event ID to your backend. From there, your server can call the Fingerprint Events API to retrieve the full visitor information data and use it to make decisions and prevent fraud. Check out these related resources: