Skip to content

Conversation

@HugoRCD
Copy link
Member

@HugoRCD HugoRCD commented Dec 11, 2025

This PR restructures the Nuxt module to provide a cleaner developer experience.

One-line usage

For Nuxt users wanting to enable Vercel Analytics without the need to configure anything:

// nuxt.config.ts
export default defineNuxtConfig({
  modules: ['@vercel/analytics']
})

Custom usage

If the user needs to specify options, they can use the injectAnalytics function in a Nuxt plugin:

// app/plugins/analytics.ts
import { injectAnalytics } from "@vercel/analytics/nuxt/runtime"

export default defineNuxtPlugin(() => {
  injectAnalytics({
    beforeSend(event) {
      if (event.url.includes('/private')) {
        return null;
      }
      return event
    }
  })
})

Using track in components

To track custom events in your Vue components:

<script setup>
import { track } from "@vercel/analytics/nuxt/runtime"
</script>

<template>
  <button @click="track('button-click', { page: $route.path })">
    Click me
  </button>
</template>

Component usage

Using the <Analytics> component is still supported but should not be recommended as it needs to be set in both app.vue and error.vue.

@HugoRCD HugoRCD self-assigned this Dec 11, 2025
@vercel
Copy link

vercel bot commented Dec 11, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
analytics-astro Ready Ready Preview, Comment Dec 22, 2025 5:10pm
analytics-next15 Ready Ready Preview, Comment Dec 22, 2025 5:10pm
analytics-nextjs Ready Ready Preview, Comment Dec 22, 2025 5:10pm
analytics-nuxt Ready Ready Preview, Comment Dec 22, 2025 5:10pm
analytics-remix Ready Ready Preview, Comment Dec 22, 2025 5:10pm
analytics-sveltekit Ready Ready Preview, Comment Dec 22, 2025 5:10pm
analytics-vue Ready Ready Preview, Comment Dec 22, 2025 5:10pm

Copy link
Member

@feugy feugy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot!

@feugy feugy merged commit c5875a7 into canary Dec 22, 2025
11 of 12 checks passed
@feugy feugy deleted the feat/nuxt-as-a-module branch December 22, 2025 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants