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

@pageviews/tracker

v0.4.0

Published

Lightweight, cookie-free analytics tracker for PageViews.ai

Readme

@pageviews/tracker

The official JavaScript SDK for Pageviews.ai — a lightweight, cookie-free analytics platform built for privacy.

Use this package to add analytics to React, Vue, Next.js, or any other JavaScript framework with full programmatic control over pageview and event tracking.

For simple script tag installation (no build step), see the Script Tag guide instead.

Features

  • Cookie-free and GDPR-compliant — no consent banner required
  • Automatic pageview tracking for SPAs (React Router, Vue Router, Next.js App Router)
  • Custom event tracking with properties and revenue data
  • Engagement tracking — active time and scroll depth per page
  • Auto-tracking for outbound links, file downloads, and form submissions
  • Realtime User Explorer via identify()
  • Full TypeScript support

Installation

npm install @pageviews/tracker

Quick Start

import { init, track, identify } from '@pageviews/tracker'

// Initialize once at your app's entry point
await init({ siteId: 'your-site-id' })

// Track custom events
track('signup', { props: { plan: 'pro' } })

// Identify a logged-in user for the Realtime User Explorer
identify({ userId: 'user-123' })

Your site ID is available in the Pageviews dashboard under Settings → Tracking.

Framework Examples

Next.js (App Router)

// app/providers.tsx
'use client'

import { useEffect } from 'react'
import { init, destroy } from '@pageviews/tracker'

export function Providers({ children }: { children: React.ReactNode }) {
  useEffect(() => {
    init({ siteId: 'your-site-id' })
    return () => destroy()
  }, [])

  return <>{children}</>
}

React

// Entry point or layout component
import { useEffect } from 'react'
import { init, destroy } from '@pageviews/tracker'

export function AnalyticsProvider({ children, siteId }) {
  useEffect(() => {
    init({ siteId })
    return () => destroy()
  }, [siteId])

  return children
}

Vue

// main.js
import { init } from '@pageviews/tracker'

init({ siteId: 'your-site-id' })

API

init(options): Promise<void>

Initializes the tracker. Call once at your app's entry point.

await init({
  siteId: 'your-site-id',   // required — from your Pageviews dashboard
  endpoint?: string,         // optional — custom ingest URL (self-hosted / proxy)
  configEndpoint?: string,   // optional — custom config URL
})

On init, site configuration (routing mode, auto-tracking rules, scroll goals) is fetched from the Pageviews API and cached in localStorage for 1 hour.

track(eventName, options?): void

Sends a custom event.

track('purchase', {
  props: { plan: 'pro', annual: true },
  revenue: { amount: 49, currency: 'USD' },
  callback: (result) => console.log(result),
})

identify(data): void

Associates a user identifier with the current session. Appears in the Realtime User Explorer in the dashboard. Not persisted to the database — stored in memory only for the duration of the session.

identify({ userId: 'user-123' })

destroy(): void

Stops all tracking and resets state. Useful for SPA cleanup or testing. init() can be called again after destroy().

Privacy

  • No cookies or persistent browser identifiers set
  • Query parameters containing potential PII are stripped from URLs before sending — only UTM parameters and ref are kept
  • Referrer query strings are stripped entirely — only the domain and path are sent
  • IP addresses are hashed server-side with a daily-rotating salt and never stored in raw form
  • No cross-site tracking

Full Documentation

For configuration options, advanced usage, and the script tag installation method, see the full docs:

pageviews.ai/docs/npm-module-at-pageviewstracker