Overview
In this quickstart, you’ll add Fingerprint to a new Angular v19 project and identify the user’s device. The example use case we’ll use for 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 front-end integration. You’ll install the Fingerprint Angular SDK and initialize the client to generate a request ID to send to your back end for analysis. To see how to implement fraud prevention with this ID, continue to one of our back-end 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 Angular and JavaScript/Typescript
This quickstart only covers the front-end setup. You’ll need a back-end
server to receive and process the device
identification event to enable fraud detection. Check out one of our back-end
quickstarts after completing this
quickstart.
1. Create a Fingerprint account and get your API key
- Sign up for a free Fingerprint trial if you don’t already have an account.
- After signing in, go to the API keys page in the dashboard.
- Copy your public API key; you’ll need it to initialize the Fingerprint client agent.
2. Set up your project
To get started, create a new Angular project. If you already have a project you want to use, you can skip to the next section.- Install the Angular CLI:
Terminal
- Create a new project:
Terminal
Do you want to enable Server-Side Rendering (SSR) and Static Site Generation (SSG/Prerendering)?, select No.
After you select the configuration options and the CLI runs through the setup, you should see the following message:
Terminal
- Change into the project folder:
Terminal
- Open the
fingerprint-angular-quickstartfolder in your code editor and you’re ready to go! To run your project, run:
Terminal
- In your browser, go to http://localhost:4200, and you should see the Angular welcome page. The application will automatically reload whenever you modify any of the source files.
3. Set up your account creation form
- Before hooking up Fingerprint, create a new component at
src/app/create-account-form/create-account-form.component.tswith the following:
src/app/create-account-form/create-account-form.component.ts
- Import and add the component to your
Appinsrc/app/app.ts:
src/app/app.ts
4. Install and initialize the Fingerprint SDK
- To integrate Fingerprint into your Angular app, first add the SDK via npm:
Terminal
Since Angular v19 no longer uses NgModule-based structure, and the current
Fingerprint SDK was built for earlier versions, we’ll create a helper function
to export the necessary method..
- Create a
src/app/utils/fingerprint.provider.tsfile with the following code:
src/app/utils/fingerprint.provider.ts
- Now that we have
provideFingerprintPro, import and initialize it in your app config entry point. Opensrc/app/app.config.tsand add the Fingerprint providerprovideFingerprintProfunction into theprovidersarray of the config option:
src/app/app.config.ts
- Replace
<your-public-api-key>with your actual public API key from the Fingerprint dashboard.
5. Trigger visitor identification
Now that the Fingerprint client is initialized, you can identify the visitor only when needed. In this case, that’s when the user taps/clicks the Create Account button. When making the visitor identification request, you will receive thevisitorId as well as a requestId. Instead of using the visitorId returned directly on the front end (which could be tampered with), you’ll send the requestId to your back end. 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.
- Within the empty
CreateAccountFormComponentclass increate-account-form.component.ts, declare username and password as properties with empty strings as initial value to track your form inputs. Also importFingerprintjsProAngularService:
src/app/create-account-form/create-account-form.component.ts
- Configure the Fingerprint service by passing it into the
CreateAccountFormComponentclassconstructor. This automatically initializes it viaDependency Injection:
src/app/create-account-form/create-account-form.component.ts
- Define the submit handler to trigger identification when the user clicks Create Account:
src/app/create-account-form/create-account-form.component.ts
this.isLoading = trueis used to monitor the process stage for the function call.const data = await this.fingerprintService.getVisitorData();— This triggers Fingerprint’s device identification and returns adataobject containing the visitor’svisitorIdandrequestId, which you can then send to your back end along with the username and password.
6. Test the app
- If your dev server isn’t already running, start it with:
Terminal
- In your browser, go to http://localhost:4200 (Angular’s default).
- If you have any ad blockers, turn them off for localhost. View our documentation to learn how to protect your Fingerprint implementation from ad blockers in production.
- Enter a username and password, then click Create Account.
- Open the developer console in your browser, and you should see the visitor ID and request 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 therequestId to your back end. 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: