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

@bro-sdk/web

v0.1.1

Published

Web SDK for Bro analytics & push notifications platform

Readme

@bro-sdk/web

Web SDK for Bro — open-source analytics & push notifications platform.

Install

npm install @bro-sdk/web

Quick Start

import { createBro } from "@bro-sdk/web";

const bro = createBro({
  apiKey: "bro_pk_xxxxxxxxxxxx",
});

// Track events
bro.track("purchase", { amount: 99.90, currency: "BRL" });

// Identify users
bro.identify("user-123", {
  name: "Augusto",
  email: "[email protected]",
});

Use anywhere with getBro()

Initialize once at the app entry point, then access from any file:

// components/checkout.ts
import { getBro } from "@bro-sdk/web";

const bro = getBro();
bro.track("checkout_started", { cart_size: 3 });

Features

  • Auto page views — tracks navigation automatically (SPA-friendly, intercepts pushState + popstate)
  • Event batching — queues events and sends in batches (20 events or every 5s)
  • Session tracking — automatic 30-minute inactivity-based sessions
  • User identity — anonymous IDs persisted in localStorage + identified users with traits
  • Web Push — VAPID-based push notifications (no Firebase needed)
  • Click tracking — optional automatic click tracking on links/buttons
  • Offline resilience — failed batches are re-queued for retry
  • Tiny footprint — ~6KB minified

Configuration

const bro = createBro({
  apiKey: "bro_pk_xxxxxxxxxxxx",  // Required — from the Bro dashboard
  autoPageView: true,              // Auto track page views (default: true)
  trackClicks: false,              // Auto track link/button clicks (default: false)
  webPush: true,                   // Enable Web Push setup (default: false)
  vapidPublicKey: "BEl62i...",     // VAPID public key (required if webPush: true)
  serviceWorkerPath: "/bro-sw.js", // Path to the service worker (default: "/bro-sw.js")
  debug: false,                    // Log events to console (default: false)
  flushInterval: 5000,             // ms between auto-flushes (default: 5000)
  flushSize: 20,                   // Max events per batch (default: 20)
  sessionTracking: true,           // Enable session tracking (default: true)
});

API

Analytics

bro.track(name, properties?)       // Track custom event
bro.identify(userId, traits?)      // Identify user
bro.page(name?, properties?)       // Track page view manually
bro.reset()                        // Clear identity (call on logout)
bro.flush()                        // Force-send queued events
bro.shutdown()                     // Stop the SDK and flush remaining events

Web Push

await bro.subscribeToPush()        // Request permission & subscribe
await bro.unsubscribeFromPush()    // Unsubscribe from push
await bro.getPushPermission()      // Check current permission ("granted" | "denied" | "default")

Web Push Setup

1. Generate VAPID keys

npx web-push generate-vapid-keys

Save the public and private keys. Add the private key to your Bro server's environment variables (VAPID_PRIVATE_KEY) and the public key to NEXT_PUBLIC_VAPID_PUBLIC_KEY.

2. Add the service worker

Copy bro-sw.js from this package to your project's public/ folder:

cp node_modules/@bro-sdk/web/bro-sw.js public/bro-sw.js

The service worker handles incoming push notifications and click-to-open behavior. It expects a JSON payload with:

{
  "title": "Notification title",
  "body": "Notification body text",
  "image": "https://example.com/image.png",
  "url": "https://example.com/target-page",
  "data": {}
}

3. Initialize with push enabled

import { createBro } from "@bro-sdk/web";

const bro = createBro({
  apiKey: "bro_pk_xxxxxxxxxxxx",
  webPush: true,
  vapidPublicKey: "your-vapid-public-key",
});

4. Subscribe users

Call subscribeToPush() when the user opts in (e.g. after clicking a "Enable notifications" button):

const subscription = await bro.subscribeToPush();

if (subscription) {
  console.log("Push enabled!");
} else {
  console.log("User denied or browser doesn't support push");
}

The SDK automatically registers the subscription with your Bro server. Push tokens are associated with the current user (or anonymous ID).

Frameworks

Next.js / React

// app/layout.tsx or _app.tsx
"use client";
import { createBro } from "@bro-sdk/web";

createBro({
  apiKey: "bro_pk_xxxxxxxxxxxx",
  autoPageView: true,
  webPush: true,
  vapidPublicKey: "your-vapid-public-key",
});

Vite / Plain JS

// main.ts
import { createBro } from "@bro-sdk/web";

createBro({
  apiKey: "bro_pk_xxxxxxxxxxxx",
});

License

MIT