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

@nolag/notify

v0.1.1

Published

Real-time notifications SDK for NoLag — channels, read/unread tracking, badge counts

Readme

@nolag/notify

Real-time notifications SDK for NoLag — channels, read/unread tracking, and badge counts.

How It Works with NoLag

NoLag is a real-time messaging platform that handles WebSocket connections, message routing, persistence, and scaling. This SDK wraps the low-level @nolag/js-sdk and gives you a purpose-built notification API — channels, read tracking, badge counts, and replay — without managing topics or subscriptions yourself.

Getting Your Token

  1. Sign up at nolag.app
  2. Create a new project in the portal
  3. Choose the Notify blueprint when creating an app — this pre-configures the topics (notifications, _read) and settings your notification system needs
  4. Go to the app's Tokens page and generate an actor token
  5. Use that token when connecting with this SDK

Each token identifies a unique user (actor) in NoLag. The blueprint handles all the infrastructure setup — you just build your notification UI.

Install

npm install @nolag/js-sdk @nolag/notify

Quick Start

import { NoLagNotify } from "@nolag/notify";

const notify = new NoLagNotify("YOUR_ACTOR_TOKEN", {
  channels: ["alerts", "updates"],
});

await notify.connect();

// Listen for notifications
notify.on("notification", (n) => {
  console.log(`[${n.channel}] ${n.title}: ${n.body}`);
});

// Subscribe to a channel
const channel = notify.subscribe("alerts");

channel.on("notification", (n) => {
  showToast(n.title, n.body);
});

// Send a notification
channel.send("Deploy complete", {
  body: "v2.1.0 deployed to production",
  icon: "rocket",
  data: { version: "2.1.0" },
});

// Badge counts
const badges = notify.getBadgeCounts();
console.log(`Total unread: ${badges.total}`);

// Mark as read
channel.markRead(notificationId);
channel.markAllRead();

API Reference

NoLagNotify

Constructor

const notify = new NoLagNotify(token: string, options?: NoLagNotifyOptions);

Options:

| Option | Type | Default | Description | |--------|------|---------|-------------| | channels | string[] | — | Auto-subscribe to these channels on connect | | metadata | Record<string, unknown> | — | Custom metadata | | maxNotificationCache | number | 500 | Max notifications kept in memory per channel | | debug | boolean | false | Enable debug logging | | reconnect | boolean | true | Auto-reconnect on disconnect |

Methods

| Method | Returns | Description | |--------|---------|-------------| | connect() | Promise<void> | Connect to NoLag | | disconnect() | void | Disconnect | | subscribe(channelName) | NotifyChannel | Subscribe to a notification channel | | unsubscribe(channelName) | void | Unsubscribe from a channel | | getBadgeCounts() | BadgeCounts | Get unread counts (total + per channel) | | markAllRead() | void | Mark all notifications as read |

Events

| Event | Payload | Description | |-------|---------|-------------| | connected | — | Connected to NoLag | | disconnected | — | Disconnected | | reconnected | — | Reconnected after disconnect | | error | Error | Connection or protocol error | | notification | Notification | Notification received on any channel | | badgeUpdated | BadgeCounts | Badge counts changed |

NotifyChannel

Methods

| Method | Returns | Description | |--------|---------|-------------| | send(title, options?) | void | Send a notification | | markRead(id) | void | Mark a notification as read | | markAllRead() | void | Mark all in this channel as read | | getNotifications() | Notification[] | Get all cached notifications | | getUnread() | Notification[] | Get unread notifications |

Properties

| Property | Type | Description | |----------|------|-------------| | name | string | Channel name | | notifications | Notification[] | Cached notifications | | unreadCount | number | Unread count | | active | boolean | Whether currently subscribed |

Events

| Event | Payload | Description | |-------|---------|-------------| | notification | Notification | Notification received | | read | string | Notification marked as read (id) | | readAll | — | All marked as read | | replayStart | — | Replay started | | replayEnd | — | Replay finished |

Types

interface Notification {
  id: string;
  channel: string;
  title: string;
  body?: string;
  icon?: string;
  data?: Record<string, unknown>;
  timestamp: number;
  read: boolean;
  isReplay: boolean;
}

interface BadgeCounts {
  total: number;
  byChannel: Record<string, number>;
}

interface SendNotificationOptions {
  body?: string;
  icon?: string;
  data?: Record<string, unknown>;
}

License

MIT