npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

nextrack

v0.1.4

Published

Deep user activity tracking for Next.js — everything Google Analytics doesn't tell you

Downloads

497

Readme

nextrack

Deep user activity tracking for Next.js — the things Google Analytics doesn't tell you.

npm version license

Rage clicks · Dead clicks · Scroll depth · Attention time · Form abandonment · Tab switches · Copy events · Web Vitals · JS Errors · Custom events — all in one package, stored in your own Supabase database.


Features

| Feature | Included | |---|:---:| | Page views | ✅ | | Custom events | ✅ | | Rage clicks (frustrated users) | ✅ | | Dead clicks (broken UI) | ✅ | | Click heatmaps | ✅ | | Real engaged time (not idle time) | ✅ | | Tab switch count | ✅ | | Form field abandonment | ✅ | | Copy events | ✅ | | JS error tracking | ✅ | | Web Vitals (LCP/FCP/CLS/INP/TTFB) | ✅ | | Your own database | ✅ | | No cookie banner needed (no PII) | ✅ |


Installation

npm install nextrack
# or
pnpm add nextrack
# or
yarn add nextrack

Peer dependencies:

npm install @supabase/supabase-js

Prerequisites

Run the database migration in your Supabase project → SQL Editor:

-- copy contents from:
-- https://github.com/mustafaag/nextrack/blob/main/supabase/migrations/001_create_tracker_tables.sql

Quick start

1. Add the provider to your root layout

// app/layout.tsx
import { TrackerProviderWrapper } from '@/components/TrackerProviderWrapper'

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html>
      <body>
        <TrackerProviderWrapper>{children}</TrackerProviderWrapper>
      </body>
    </html>
  )
}
// components/TrackerProviderWrapper.tsx
'use client'
import { usePathname } from 'next/navigation'
import { TrackerProvider } from 'nextrack/react'
import { SupabaseAdapter } from 'nextrack/adapters/supabase'
import { createClient } from '@supabase/supabase-js'

const supabase = createClient(
  process.env.NEXT_PUBLIC_SUPABASE_URL!,
  process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!
)

const adapter = new SupabaseAdapter({ client: supabase })

export function TrackerProviderWrapper({ children }: { children: React.ReactNode }) {
  const pathname = usePathname()

  return (
    <TrackerProvider
      appId="my-app"
      adapter={adapter}
      pathname={pathname}
      trackClicks
      trackScroll
      trackForms
      trackErrors
      trackWebVitals
      trackEngagement
      trackCopy
      debug={process.env.NODE_ENV === 'development'}
    >
      {children}
    </TrackerProvider>
  )
}

2. Track custom events

'use client'
import { useTracking } from 'nextrack/react'

export function CTAButton() {
  const { track } = useTracking()

  return (
    <button onClick={() => track('cta_clicked', { variant: 'hero', plan: 'pro' })}>
      Get started
    </button>
  )
}

Or use the wrapper component:

import { TrackClick } from 'nextrack/react'

<TrackClick event="upgrade_clicked" properties={{ from: 'pricing_table' }}>
  <button>Upgrade</button>
</TrackClick>

3. Identify logged-in users

const { identify } = useTracking()

// After login:
identify(user.id, { email: user.email, plan: user.plan })

HTTP adapter (optional)

If you prefer to route events through your own API instead of writing directly to Supabase from the client:

import { HttpAdapter } from 'nextrack/adapters/http'

const adapter = new HttpAdapter({
  endpoint: '/api/nextrack',
  headers: { 'x-nextrack-secret': process.env.NEXTRACK_SECRET! },
})

Add the route handler:

// app/api/nextrack/[...path]/route.ts
import { createNextHandler } from 'nextrack/next'
import { SupabaseAdapter } from 'nextrack/adapters/supabase'
import { createClient } from '@supabase/supabase-js'

const adapter = new SupabaseAdapter({
  client: createClient(
    process.env.NEXT_PUBLIC_SUPABASE_URL!,
    process.env.SUPABASE_SERVICE_ROLE_KEY!
  ),
})

const { POST, PATCH } = createNextHandler({
  adapter,
  secret: process.env.NEXTRACK_SECRET,
})

export { POST, PATCH }

Configuration options

| Option | Default | Description | |---|---|---| | appId | required | Unique app identifier | | adapter | required | Storage adapter (Supabase or HTTP) | | sampleRate | 1 | Fraction of sessions to track (0–1) | | batchSize | 10 | Events per batch flush | | flushInterval | 5000 | Flush interval in ms | | trackClicks | true | Track all clicks | | trackRageDeadClicks | true | Detect rage & dead clicks | | trackScroll | true | Scroll depth tracking | | trackForms | true | Form start/submit/abandon | | trackFormFields | false | Field-level focus/blur (privacy-sensitive) | | trackErrors | true | Uncaught JS errors | | trackWebVitals | true | LCP, FCP, CLS, TTFB, INP | | trackEngagement | true | Real attention time, tab switches | | trackCopy | true | Copy events (text length only, no content) | | idleThresholdMs | 30000 | Inactivity threshold for engagement | | rageClickCount | 3 | Clicks to trigger rage click | | rageClickWindowMs | 500 | Time window for rage click detection | | maskTextContent | false | Strip text from click selectors | | excludePaths | [] | Paths to skip (supports * wildcard) | | debug | false | Log events to console |


Privacy

  • No cookies — uses localStorage for anonymous ID, sessionStorage for session ID
  • No PII collected by default — user identification is opt-in via identify()
  • Copy events only record text length, never content
  • Click selector scrubbing via maskTextContent: true
  • RLS can be enabled on tracker tables in Supabase

Self-hosted dashboard

A full analytics dashboard is available at github.com/yourusername/nextrack.

Pages: Overview · Sessions · Events · Heatmaps · Web Vitals · Forms


License

MIT