Product analytics for Next.js
Pug’s Web SDK is framework-agnostic JavaScript — there’s no separate Next.js package to learn. Mount it once in a client component from your App Router root layout and autocapture handles the rest.
Uses the Pug Web SDK — Pug’s one framework-agnostic SDK for the browser.
npm install @poluruprvn/pug-web // app/analytics.tsx — a client component mounted in the root layout
'use client'
import { useEffect } from 'react'
import { init } from '@poluruprvn/pug-web'
export function Analytics() {
useEffect(() => {
init('your-project-id', { apiKey: 'pub_your_key' })
// Page views, clicks, scrolls, and form interactions capture from here on.
}, [])
return null
} Product analytics in your Next.js app
- Autocapture: page views, clicks, scrolls, form interactions, rage clicks, and dead clicks — after one init(), no per-event code
- identify() merges anonymous and signed-in activity into one profile per person, across devices
- track() for your own named events, with typed properties
- Trends, funnels, retention cohorts, segmentation, user flows, and top-K over every event
Pug + Next.js — common questions
Do I need a Next.js-specific package?
No — and there does not need to be one. Pug ships a single Web SDK (TypeScript/JavaScript) that runs in any browser framework, Next.js included. You install the same @poluruprvn/pug-web package and initialise it once from a client component.
Does it work with the App Router and Server Components?
Yes. Autocapture is a browser concern, so initialise the SDK in a small "use client" component mounted in your root layout. Server Components render on the server and don’t run the tracker themselves; pair the Web SDK with the Node SDK if you also want authoritative server-side events.
Can I self-host the analytics backend?
Yes — Pug is open source under AGPL-3.0. Run the whole stack on your own infrastructure, or use the free cloud during open beta. Either way your Next.js app points the SDK at your endpoint.
Add Pug to your Next.js app.
Open-source product analytics with unified profiles. Self-host under AGPL-3.0, or use the free cloud during open beta.