@fingerprint/vue

中文文档
2.1.0发布于 2026/10/28MITTypeScriptESM + CJS构建来源已验证近 30 天下载 5407

Fingerprint Vue 3 SDK

原始使用文档
文档目录16 节
  1. Requirements
  2. Installation
  3. Getting started
  4. Composition API
  5. Options API
  6. Mixins
  7. Nuxt
  8. Linking and tagging information
  9. Direct agent access
  10. Caching
  11. Migration from v1.x
  12. Documentation
  13. Version support
  14. Support and feedback
  15. Examples
  16. License

Fingerprint logo

Build status Release status Current NPM version Monthly downloads from NPM MIT license Discord server

Fingerprint Vue 3 SDK

Fingerprint is a device intelligence platform offering industry-leading accuracy.

Fingerprint Vue SDK is an easy way to integrate Fingerprint into your Vue 3 application. It supports all capabilities of the Fingerprint JavaScript agent.

Requirements

  • For Typescript users: Typescript 4.5 or higher
  • Vue 3.1 or higher
  • For Nuxt users: Nuxt 3.0 or higher

This package works with the commercial Fingerprint platform. It is not compatible with the source-available FingerprintJS library. Learn more about the differences between Fingerprint and FingerprintJS.

Installation

To install the plugin run:

yarn add @fingerprint/vue

Or:

npm install @fingerprint/vue
pnpm add @fingerprint/vue

Getting started

To identify visitors, you'll need a Fingerprint account (you can sign up for free). Get your API key and get started with the Fingerprint documentation.

Register the plugin in your Vue application.

import { createApp } from 'vue';
import App from './App.vue';
import { FingerprintPlugin } from '@fingerprint/vue';

const app = createApp(App);

app
  .use(FingerprintPlugin, {
    apiKey: '<your-public-api-key>',
    endpoints: "https://metrics.yourwebsite.com",
    region: 'eu',
  })
  .mount('#app');

You can use the plugin with Composition API, Options API, or Mixins, with or without Nuxt. See the usage examples below.

Composition API

The plugin provides a useVisitorData composable you can use to identify visitors:

<script setup>
import { useVisitorData } from '@fingerprint/vue';
import { watch } from 'vue';

const { data, error, isLoading, isFetched, getData } = useVisitorData(
  // Set to false to prevent fetching data on mount
  { immediate: false }
);

watch(data, (currentData) => {
  if (currentData) {
    // Do something with the data
    console.log(currentData.visitor_id);
  }
});
</script>

<template>
  <button @click='getData()'>Get visitor data</button>
</template>

The getData() function throws on error. You can catch errors using try/catch or check the error ref:

<script setup>
import { useVisitorData } from '@fingerprint/vue';

const { data, error, isLoading, isFetched, getData } = useVisitorData();

async function handleClick() {
  try {
    const result = await getData();
    console.log(result.visitor_id);
  } catch (err) {
    console.error('Identification failed:', err);
  }
}
</script>

Options API

The plugin injects a $fingerprint object into your components that you can use to identify visitors:

<script lang='ts'>
import { defineComponent } from 'vue';

export default defineComponent({
  methods: {
    async getVisitorData() {
      const result = await this.$fingerprint.getVisitorData();
      // Do something with result
      console.log(result.visitor_id);
    }
  }
});
</script>

<template>
  <button @click='getVisitorData'>Get visitor data</button>
</template>

Mixins

For convenience, we also provide a mixin that handles all query states:

<script lang='ts'>
import { defineComponent } from 'vue';
import { fingerprintGetVisitorDataMixin } from '@fingerprint/vue';

export default defineComponent({
  mixins: [fingerprintGetVisitorDataMixin],
  async mounted() {
    // You can also fetch data on mount
    // await this.$getVisitorData();
  }
});
</script>

<template>
  <div>
    <button @click='$getVisitorData'>
      Get visitor data
    </button>
    <span v-if='visitorData.isLoading'>
      Loading...
    </span>
    <span v-else-if='visitorData.error'>
      Error: {{ visitorData.error }}
    </span>
    <span v-else-if='visitorData.isFetched'>
      Visitor ID: {{ visitorData.data.visitor_id }}
    </span>
  </div>
</template>

Nuxt

The plugin works with Nuxt out of the box, however, you need to register it on the client side only.

// plugins/fingerprint.client.ts
import { defineNuxtPlugin, useRuntimeConfig } from '#app';
import { FingerprintPlugin } from '@fingerprint/vue';

export default defineNuxtPlugin((nuxtApp) => {
  const config = useRuntimeConfig();

  nuxtApp.vueApp.use(FingerprintPlugin, {
    apiKey: config.public.API_KEY,
    endpoints: "https://metrics.yourwebsite.com",
    region: 'eu',
  });
});
// nuxt.config.ts
import { defineNuxtConfig } from 'nuxt';

export default defineNuxtConfig({
  runtimeConfig: {
    public: {
      // Inject Fingerprint API key
      API_KEY: process.env.API_KEY,
    },
  }
});

See the example Nuxt Application for more details.

Linking and tagging information

The visitor_id provided by Fingerprint Identification is especially useful when combined with information you already know about your users, for example, account IDs, order IDs, etc. To learn more about various applications of the linkedId and tags, see Linking and tagging information.

Associate your data with a visitor ID using the linkedId or tags parameter of the useVisitorData() composable or the getData() function:

<script setup>
import { useVisitorData } from '@fingerprint/vue';

const { data, error, isLoading, getData } = useVisitorData({
  linkedId: 'user_1234',
  tags: {
    userAction: 'login',
    analyticsId: 'UA-5555-1111-1',
  },
})
</script>

<template>
<!--...-->
</template>

[!NOTE] The tag option is deprecated in favor of tags. tag still works, but if both are provided, tags takes precedence.

Direct agent access

For advanced use cases, you can access the full @fingerprint/agent API using the Fingerprint namespace export:

import { Fingerprint } from '@fingerprint/vue';

// Use agent types
type Result = Fingerprint.GetResult;
type Options = Fingerprint.GetOptions;

// Or call start() directly
const agent = Fingerprint.start({ apiKey: '...' });
const result = await agent.get();

Caching

Fingerprint usage is billed per API call. To avoid unnecessary API calls, it is a good practice to cache identification results.

Caching is disabled by default, aligned with the underlying JavaScript agent v4 default. To enable caching, pass the cache start option:

app.use(FingerprintPlugin, {
  apiKey: '<your-public-api-key>',
  cache: {
    storage: 'sessionStorage', // or 'localStorage' or 'agent'
    duration: 'optimize-cost', // or 'aggressive' or a number in seconds
  },
});

Migration from v1.x

Version 2.0 upgrades the underlying Fingerprint agent from v3 to v4 and introduces several breaking changes. See the migration guide for detailed instructions and the JavaScript agent v3 to v4 migration guide for underlying agent changes.

Documentation

You can find detailed documentation in the API reference.

Version support

SDK major versionJS Agent versionStatusEnd of support
v2.x (current)v4Supported-
v1.xv3Deprecated (security fixes only). See the migration guide.To be decided

Support and feedback

To ask questions or provide feedback, use Issues. If you need private support, please email us at [email protected]. If you'd like to have a similar Vue wrapper for the source-available FingerprintJS, consider creating an issue in the main FingerprintJS repository.

Examples

You can find the following examples in the examples directory:

License

This project is licensed under the MIT license.

版本与发布记录

@fingerprint/vue 共发布 3 个版本,首次发布于 2026/04/16;过去 12 个月发布了 3 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
2.1.0latest2026/10/2817 天前
2.0.02026/04/176 个月前
2.0.0-rc.0rc2026/04/166 个月前

关于 @fingerprint/vue 的常见问题

@fingerprint/vue 是什么?

Fingerprint Vue 3 SDK

如何安装 @fingerprint/vue?

在项目目录运行 npm install @fingerprint/vue,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:vue(^3.1)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@fingerprint/vue 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@fingerprint/vue 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@fingerprint/vue 可以商用吗?

@fingerprint/vue 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@fingerprint/vue 的下载量有多少?

根据 npm 官方下载统计,@fingerprint/vue 在 2026/10/15 – 2026/11/13 这 30 天内被下载 5,407 次,日均约 180 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@fingerprint/vue 还在维护吗?

最新版本 2.1.0 发布于 2026/10/28(17 天前);至今共发布 3 个版本,其中过去 12 个月发布了 3 个;首次发布于 2026/04/16。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。