Clarity
Clarity by Microsoft is a screen recorder and heatmap tool that helps you understand how users interact with your website.
Nuxt Config Setup
Add this to your nuxt.config.ts to load Clarity globally. Alternatively you can use the useScriptClarity composable for more control.
export default defineNuxtConfig({
scripts: {
registry: {
clarity: {
id: 'xxxxxxxxxx',
trigger: 'onNuxtReady',
}
}
}
})This config automatically enables first-party mode (bundle + proxy). See below to customise.
useScriptClarity()
The useScriptClarity composable lets you have fine-grain control over when and how Clarity is loaded on your site.
const { proxy } = useScriptClarity()
proxy.clarity('event', 'conversion')Please follow the Registry Scripts guide to learn more about advanced usage.
First-Party Mode: Privacy Focused Proxy
No extra config needed. The script is bundled from your domain (faster loads, no extra DNS lookup) and runtime requests are reverse-proxied through your server with automatic anonymisation (user IPs stay hidden from Clarity, works with ad blockers). Learn more.
export default defineNuxtConfig({
scripts: {
// ✅ First-party mode: bundled + proxied
registry: {
clarity: {
id: 'xxxxxxxxxx',
trigger: 'onNuxtReady',
},
},
},
})Example
Using Clarity in a component with the proxy to send events .
<script setup lang="ts">
const { proxy } = useScriptClarity()
// noop in development, ssr
// just works in production, client
function handleAction() {
proxy.clarity('event', 'conversion')
}
</script>
<template>
<div>
<button @click="handleAction">
Send Event
</button>
</div>
</template>idstring required The Clarity token.