Skip to main content

Vue usage

Vue 3 integration for ThumbmarkJS - browser fingerprinting library.

Installation

npm install @thumbmarkjs/thumbmarkjs @thumbmarkjs/vue

Usage

1. Install the plugin

import { createApp } from 'vue';
import { createThumbmarkPlugin } from '@thumbmarkjs/vue';

const app = createApp(App);
app.use(createThumbmarkPlugin());
app.mount('#app');

2. Use the composable

<template>
<div v-if="isLoading">Loading...</div>
<div v-else-if="error">Error: {{ error.message }}</div>
<div v-else>
<div>Visitor ID: {{ visitorId }}</div>
<div>Thumbmark: {{ thumbmark }}</div>
<button @click="reload">Reload</button>
</div>
</template>

<script setup>
import { useThumbmark } from '@thumbmarkjs/vue';

const { thumbmark, visitorId, isLoading, error, reload } = useThumbmark();
</script>

With API Key

app.use(createThumbmarkPlugin({
apiKey: 'your-key'
}));

With Options

app.use(createThumbmarkPlugin({
apiKey: 'your-key',
options: {
timeout: 3000,
exclude: ['webgl']
}
}));

API

createThumbmarkPlugin(options?)

OptionTypeDescription
apiKeystringOptional API key for the hosted ThumbmarkJS API
optionsThumbmarkOptionsOptional configuration options passed to the underlying Thumbmark instance

useThumbmark()

Returns reactive refs:

FieldTypeDescription
thumbmarkRef<string | null>The generated thumbmark hash
visitorIdRef<string | null>The visitor ID (when API is used)
componentsRef<Record<string, any> | null>Raw fingerprint components
infoRef<Record<string, any> | null>Additional info returned by the API
isLoadingRef<boolean>Loading state
errorRef<Error | null>Error state
reload() => Promise<void>Re-generate the thumbmark

The composable is SSR-safe — it only runs on the client.

See also the configuration options.