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

@serge-ai/react

v0.2.2

Published

Serge for React — drop-in <Analytics /> + <DetectionPixel /> components for catching AI-agent sessions on your site.

Readme

@serge-ai/react

No cookies. No localStorage by default. No consent banner required. ePrivacy Art. 5(3) compliant by construction.

React integration for Serge — drop-in <Analytics /> and <DetectionPixel /> components for catching AI-agent sessions on your site.

pnpm add @serge-ai/react
# or
npm install @serge-ai/react

For Next.js App Router consumers → use @serge-ai/nextjs instead — it auto-tracks route changes via usePathname / useSearchParams.

For vanilla JS / Vue / Svelte → use @serge-ai/js.

Quick start

import { Analytics, DetectionPixel, track } from '@serge-ai/react'

export function App() {
  return (
    <>
      <Analytics token="srg_pub_xxxxxxxxxxxxxxxxxxxxxxxxxx" />
      <DetectionPixel token="srg_pub_xxxxxxxxxxxxxxxxxxxxxxxxxx" />
      <button onClick={() => track('signup_clicked')}>Sign up</button>
    </>
  )
}

<Analytics /> catches JS-driven agents (browser extensions, browser-use, Operator, ChatGPT Atlas, Claude Computer Use). <DetectionPixel /> catches HTML-only agents that don't execute JS (ChatGPT-User, Claude-User, GPTBot, ClaudeBot, PerplexityBot). The pixel is what makes Serge see traffic that PostHog, GA4, and Hotjar miss entirely.

Components

<Analytics />

Drop-in component. Calls init() once on mount, returns null.

<Analytics
  token="srg_pub_xxx"
  apiBase="https://serge.ai"  // optional first-party proxy override
  debug={false}                // optional
  requireConsent={false}       // optional
/>

Re-renders only re-call init() if the token changes. Other config edits require a remount — the tracker's runtime state is module-level and changing flags mid-session produces unpredictable behavior.

<DetectionPixel />

Renders an invisible 1×1 GIF that catches non-JS agents. Drop next to <Analytics />.

<DetectionPixel
  token="srg_pub_xxx"
  apiBase="https://serge.ai"   // optional
/>

The image fetch fires from the agent direct to the Serge ingest endpoint with the agent's User-Agent intact. Serge's server matches the UA against known agent patterns (ChatGPT-User, Claude-User, GPTBot, ClaudeBot, PerplexityBot, …), validates the Referer against your registered domain, then writes the hit to your dashboard. No competing analytics SDK ships this.

API re-exports

import { init, track, consent, pageview } from '@serge-ai/react'

These are re-exports from @serge-ai/js so consumers can import everything from one path. See @serge-ai/js docs for the full reference.

SSR safety

Every browser-API access is guarded inside useEffect. Components are marked 'use client'. Safe to import from server components, RSC layouts, Edge runtimes.

Why no <TrackerProvider> / useTracker() hook?

PostHog tried both patterns; the convergent industry pattern is the singleton init() + import-anywhere model (Sentry, Mixpanel, Amplitude, Segment all do this). The provider+hook adds context-render overhead without giving the consumer anything they couldn't get from the singleton import. We dropped them in 0.2.0.

Why no identify()?

Serge measures agent sessions, not end-users. Per-user identity is anti-goal for cookieless agent analytics. See @serge-ai/js README for the reasoning.

React versions

react@^18 || ^19 (peer dependency). Works in both 18 and 19.

Bundle size

Under 6 KB gzipped (excluding react and @serge-ai/js, which the host already provides). size-limit enforces this in CI.

License

MIT © Superstellar LLC. See LICENSE.