💚

Beam for Nuxt

Add cookie-free, GDPR-compliant analytics to your Nuxt 3 app in under 2 minutes. No consent banner required. Uses the Nuxt plugin system and Vue Router's afterEach guard for full SPA route coverage.

Get started free Explore live demo

No credit card required and setup in minutes

Install Beam on Nuxt

Replace YOUR_SITE_ID with your Beam site ID from the dashboard.

Create a Nuxt client plugin: plugins/beam.client.ts

// plugins/beam.client.ts
// The .client.ts suffix ensures this runs only in the browser (not during SSR).

export default defineNuxtPlugin((nuxtApp) => {
  // Inject the Beam script once on app init
  const script = document.createElement('script')
  script.defer = true
  script.src = 'https://beam-privacy.com/js/beam.js'
  script.setAttribute('data-site-id', 'YOUR_SITE_ID')
  document.head.appendChild(script)

  // Track SPA navigations with Vue Router afterEach
  const router = useRouter()
  router.afterEach((to) => {
    // Wait a tick for the script to initialise on first load
    nextTick(() => {
      window.beam?.track?.('pageview', { path: to.fullPath })
    })
  })
})

Nuxt auto-discovers plugins in the plugins/ directory. The .client.ts suffix tells Nuxt to skip this plugin during server-side rendering, so document and window are always available.

Alternative: npm package install

# Install the Beam npm package
npm install @keylightdigital/beam

# Then in plugins/beam.client.ts, import directly:
import { trackPageview } from '@keylightdigital/beam'

export default defineNuxtPlugin(() => {
  const router = useRouter()
  router.afterEach((to) => {
    nextTick(() => trackPageview(to.fullPath))
  })
})

The npm package is available for teams that prefer build-tool integration. The script-tag approach above is simpler and needs no bundler changes.

Verify your Nuxt integration

Use this checklist after publish so you know tracking is actually live in production.

  • Run nuxi dev and open the app in a browser.
  • Navigate between two routes using components (not browser refresh).
  • Open your Beam dashboard and confirm both paths appear in Top Pages within a minute.
  • Check that no cookies or localStorage keys are set by the Beam script.

Why Beam works well for Nuxt

🍪

No cookie banner required

Beam is cookie-free by design — no consent UI to build, no GDPR overhead for your Nuxt 3 app.

Sub-2KB, SSR-safe

The .client.ts plugin pattern keeps Beam out of SSR entirely, so your Nuxt server render is never affected.

🧭

Full SPA route tracking

The afterEach guard captures every Vue Router navigation in your Nuxt app so Top Pages stays accurate across all routes.

🔒

Privacy by default

No PII, no fingerprinting, no ad-tech — just page-level metrics your team can act on.

Ready to add Beam to Nuxt?

Start free, validate your first pageview, and then scale when traffic grows.

Related setup guides