Nuxt 2 reached End-of-Life on June 30th, 2024.


Add HotJar to your Nuxt application


Nuxt Hotjar

Easily add Hotjar for tracking and analytics to your Nuxt application.

npm versionnpm downloadsLicenseNuxt


  • 🔥 Easily add Hotjar to your Nuxt application
  • 👮 Data privacy
  • 🏷️ Fully typed
  • 🦾 SSR support


npx nuxi@latest module add hotjar


Add nuxt-module-hotjar to the modules section of nuxt.config.ts and provide your Hotjar site id and the script version.

In order for Nuxt Hotjar to run, it needs to be initialized with your site ID (this is the hotjarId in our module). You can find your site ID on this page just before your site name.

export default defineNuxtConfig({
  modules: [

  hotjar: {
    hotjarId: 1234567,
    scriptVersion: 6,

    // optionally you can turn on debug mode for development
    debug: true

Basic usage

Now you have to initialize Hotjar in your app with the composable useHotjar:

// In you app.vue file for example when you user has given consent:

const { initialize } = useHotjar()

function onConsent() {



The SSR-safe useHotjar composable provides access to:

  • The initialize method

You can use it like this:

const { initialize } = useHotjar()

Types declarations

function useHotjar(): {
  initialize: () => void

Modules Options

hotjarIdnumberundefinedYour Hotjar site_id.
scriptVersionnumber6By default it's 6, you don’t necessarily need to change it.
debugbooleanfalseDebug mode



# Install dependencies
npm install

# Generate type stubs
npm run dev:prepare

# Develop with the playground
npm run dev

# Build the playground
npm run dev:build

# Run ESLint
npm run lint

# Run Vitest
npm run test
npm run test:watch

# Release new version
npm run release