Add cookie-free, GDPR-compliant analytics to your Next.js application in under 2 minutes. No consent banners. No performance hit. Works with App Router and Pages Router.
No credit card required and setup in minutes
Replace YOUR_SITE_ID with your Beam site ID from the dashboard.
// app/layout.tsx
import Script from 'next/script'
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en">
<head />
<body>
{children}
<Script
src="https://beam.keylightdigital.dev/js/beam.js"
data-site-id="YOUR_SITE_ID"
strategy="afterInteractive"
/>
</body>
</html>
)
}
Use strategy="afterInteractive" so Beam loads after hydration with minimal performance impact.
# Install the package
npm install beam-analytics
# In app/layout.tsx or pages/_app.tsx
import { useBeam } from 'beam-analytics/react'
export default function RootLayout({ children }) {
useBeam('YOUR_SITE_ID')
return <>{children}</>
}
The React hook auto-tracks page navigations in both App Router and Pages Router with no custom router events.
Use this checklist after publish so you know tracking is actually live in production.
Beam never sets cookies or stores personal data. Your Next.js app stays GDPR and CCPA compliant with no legal pop-up work.
The script is under 2KB and loads asynchronously, keeping LCP and CLS unaffected in normal production conditions.
Works with Next.js 13+ App Router, Pages Router, and static exports without server-side refactors.
Track top routes, channels, referrers, and devices in one dashboard instead of GA-style report sprawl.
Start free, validate your first pageview, and then scale when traffic grows.