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

@notify.partners/web-sdk

v1.0.0

Published

Notify Partners Web SDK for browser push notifications

Readme

Notify Partners Web SDK

Push notification SDK for browsers with Web Push and Service Worker support.

Features

  • Automatic lifecycle tracking — no manual foreground/background calls needed
  • Debounced updates — rapid setExternalId/setTags calls coalesce into one request
  • Exponential backoff retry — 3 policies (INIT / UPDATE / EVENT) for reliability
  • Input validation — catches configuration errors early
  • Structured errorsSdkError with typed error discrimination
  • Tree-shakeable ESM + UMD bundle for CDN usage
  • TypeScript-first — full type definitions included

Requirements

  • Modern browser with Service Worker and Push API support
  • HTTPS (required for Service Workers)
  • VAPID key pair from the Notify Partners dashboard

Installation

npm

npm install @notify.partners/web-sdk

CDN

<script src="https://cdn.jsdelivr.net/npm/@notify.partners/web-sdk/dist/notify-partners-sdk.umd.js"></script>

Quick Start

1. Copy the Service Worker

Copy node_modules/@notify.partners/web-sdk/dist/notify-partners-sw.js to the root of your website (so it's accessible at /notify-partners-sw.js).

2. Initialize the SDK

import { NotifyPartnersSDK } from '@notify.partners/web-sdk';

NotifyPartnersSDK.initialize({
  appId: 'your-app-id',
  vapidKey: 'your-vapid-public-key',
});

That's it. The SDK automatically handles:

  • Notification permission request
  • Service Worker registration and push subscription
  • Lifecycle tracking (page visible / hidden / closed)
  • Periodic device info updates

3. Set user properties (optional)

NotifyPartnersSDK.setExternalId('user-123');
NotifyPartnersSDK.setTags({ plan: 'premium', locale: 'en' });

Advanced Configuration

import { NotifyPartnersSDK } from '@notify.partners/web-sdk';

NotifyPartnersSDK.initialize({
  appId: 'your-app-id',
  vapidKey: 'your-vapid-public-key',
  externalId: 'user-123',
  tags: { plan: 'premium' },
  baseUrl: 'https://custom-api.example.com/api/v3',
  serviceWorkerPath: '/custom-sw.js',
  debug: true,
  listener: {
    onInitialized(instanceId) {
      console.log('SDK ready:', instanceId);
    },
    onInitializationFailed(error) {
      console.error('SDK failed:', error.type, error.message);
    },
    onMessageReceived(msgId, title, body, data) {
      console.log('Push received:', title, body);
    },
  },
});

API Reference

NotifyPartnersSDK

| Method | Description | |--------|-------------| | initialize(config) | Initialize the SDK. Fire-and-forget — errors go to the listener. | | shutdown() | Release all resources. Allows re-initialization. | | setExternalId(id) | Set external user ID (max 256 chars). Debounced. | | setTags(tags) | Set tags for segmentation (max 50). Debounced. | | isInitialized() | Returns true if the SDK is ready. | | getInstanceId() | Returns the server-assigned instance ID. | | setListener(listener) | Replace the lifecycle listener. |

NotifyPartnersConfig

| Field | Type | Default | Description | |-------|------|---------|-------------| | appId | string | required | Application ID from the dashboard | | vapidKey | string | required | VAPID public key | | externalId | string? | — | External user ID (max 256 chars) | | tags | Record<string,string>? | — | User tags (max 50, key ≤128, value ≤256) | | baseUrl | string? | https://api.notify.partners/api/v3 | API base URL | | serviceWorkerPath | string? | /notify-partners-sw.js | Path to the SW file | | debug | boolean? | false | Enable debug logging | | listener | NotifyPartnersListener? | — | Lifecycle callbacks |

SdkError

Structured error with a type discriminant for switch-based handling:

import { SdkError } from '@notify.partners/web-sdk';

// In your listener:
onInitializationFailed(error) {
  switch (error.type) {
    case 'ConfigurationError':
      console.error('Bad config:', error.message);
      break;
    case 'NetworkError':
    case 'TimeoutError':
      console.error('Network issue, will retry');
      break;
    case 'ServerError':
      console.error('Server error:', error.httpCode);
      break;
    case 'ClientError':
      console.error('Client error:', error.httpCode, error.body);
      break;
  }
}

CDN / Script Tag

<script src="https://cdn.jsdelivr.net/npm/@notify.partners/web-sdk/dist/notify-partners-sdk.umd.js"></script>
<script>
  NotifyPartners.NotifyPartnersSDK.initialize({
    appId: 'your-app-id',
    vapidKey: 'your-vapid-public-key',
  });
</script>

Service Worker Setup

The service worker file must be served from the root of your domain (or the scope you want to cover). It handles:

  • Showing push notifications
  • Reporting delivery and click events to the backend
  • Opening URLs when notifications are clicked
  • Forwarding push payloads to the main thread

If using a bundler, copy the file during your build:

# Example with cp
cp node_modules/@notify.partners/web-sdk/dist/notify-partners-sw.js public/

License

MIT