Skip to content

Conversation

@atinux
Copy link
Member

@atinux atinux commented Nov 19, 2025

This pull request improve the Nuxt usage.

One-line usage

For Nuxt users wanting to enable Vercel Analytics without the need to configure anything, it will be as simple as doing:

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

*There is an ongoing work on Nuxt side to give the possibility to use @vercel/analytics/nuxt as Nuxt module

Custom usage

Similar to the SvelteKit approach, if the user needs to specify options, it can use the injectAnalytics method:

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

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

Component usage

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

@vercel
Copy link

vercel bot commented Nov 19, 2025

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

Project Deployment Preview Comments Updated (UTC)
analytics-astro Ready Ready Preview Comment Nov 24, 2025 5:46pm
analytics-next15 Ready Ready Preview Comment Nov 24, 2025 5:46pm
analytics-nextjs Ready Ready Preview Comment Nov 24, 2025 5:46pm
analytics-nuxt Ready Ready Preview Comment Nov 24, 2025 5:46pm
analytics-remix Ready Ready Preview Comment Nov 24, 2025 5:46pm
analytics-sveltekit Ready Ready Preview Comment Nov 24, 2025 5:46pm
analytics-vue Ready Ready Preview Comment Nov 24, 2025 5:46pm

@atinux
Copy link
Member Author

atinux commented Nov 24, 2025

I had to set Node to 22 due to an error of SvelteKit requiring either Node 20 or 22 😄

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.

Perfect!!
The module pattern is so much better.

Let's apply these comments to the speed insights PR now.

@feugy feugy merged commit 9a406c4 into main Nov 25, 2025
13 checks passed
@feugy feugy deleted the feat/nuxt-module branch November 25, 2025 07:58
atinux added a commit that referenced this pull request Dec 1, 2025
This reverts commit #178 as the Nuxt module should be a breaking change.
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.

4 participants