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

@arkstack/realtime

v0.17.12

Published

Client for consuming Arkstack realtime notifications (Pusher/Firebase), with framework-agnostic core plus React and Vue bindings.

Readme

@arkstack/realtime

@arkstack/realtime

The client for consuming Arkstack realtime notifications. A framework-agnostic core plus React and Vue bindings, backed by Pusher or Firebase Cloud Messaging.

Pairs with the realtime notification driver in @arkstack/notifications, which broadcasts a per-user channel (user.<id>) that this client subscribes to.

Install

pnpm add @arkstack/realtime

Then install the client SDK for your transport (both are optional peer dependencies — install only the one you use):

pnpm add pusher-js   # Pusher transport
pnpm add firebase    # Firebase transport

Usage

Create a client and subscribe to a user's channel. subscribe/forUser resolve to an unsubscribe function.

import { createRealtime } from '@arkstack/realtime';

const realtime = createRealtime({
  transport: 'pusher',
  pusher: {
    key: import.meta.env.VITE_PUSHER_KEY,
    cluster: 'mt1',
    authEndpoint: '/broadcasting/auth',
  },
});

const unsubscribe = await realtime.forUser(user.id, (notification) => {
  console.log(notification.title, notification.description);
});

// later
unsubscribe();
await realtime.disconnect();

Each notification matches the payload broadcast by the server:

interface RealtimeNotification {
  id: string;
  type: string | null;
  title: string;
  description: string;
  actionText?: string | null;
  actionLink?: string | null;
  meta?: Record<string, unknown> | null;
  read_at: string | null;
  created_at: string;
}

React

import { useNotifications } from '@arkstack/realtime/react';

function Bell({ realtime, userId }) {
  const { notifications, latest, clear } = useNotifications(
    realtime,
    realtime.channelFor(userId),
    { limit: 20 },
  );

  return (
    <span onClick={clear}>
      {notifications.length} · {latest?.title}
    </span>
  );
}

The hook accumulates notifications (newest first), caps them at limit, and unsubscribes automatically on unmount or when client/channel change.

Vue

<script setup>
import { useNotifications } from '@arkstack/realtime/vue';

const props = defineProps(['realtime', 'userId']);
const { notifications, latest, clear } = useNotifications(
  props.realtime,
  props.realtime.channelFor(props.userId),
  { limit: 20 },
);
</script>

<template>
  <span @click="clear">{{ notifications.length }} · {{ latest?.title }}</span>
</template>

The composable unsubscribes automatically when the component's scope is disposed.

Firebase

Firebase Cloud Messaging delivers to the device (via onMessage), so notifications are matched by event name rather than channel:

const realtime = createRealtime({
  transport: 'firebase',
  firebase: {
    apiKey: import.meta.env.VITE_FIREBASE_API_KEY,
    projectId: import.meta.env.VITE_FIREBASE_PROJECT_ID,
    appId: import.meta.env.VITE_FIREBASE_APP_ID,
    messagingSenderId: import.meta.env.VITE_FIREBASE_SENDER_ID,
  },
});

Custom transport

Provide transportFactory to bridge any backend (a raw WebSocket, SSE, a test double, …):

import { createRealtime, type RealtimeTransport } from '@arkstack/realtime';

const transport: RealtimeTransport = {
  subscribe(channel, event, handler) {
    const socket = new WebSocket(`wss://example.test/${channel}`);
    socket.addEventListener('message', (e) => {
      const { event: name, payload } = JSON.parse(e.data);
      if (name === event) handler(payload);
    });

    return { channel, unsubscribe: () => socket.close() };
  },
  disconnect() {},
};

const realtime = createRealtime({ transportFactory: () => transport });

API

  • createRealtime(config) — create a RealtimeClient. Config: transport ('pusher' | 'firebase'), event (default notification), channelPrefix (default user.), pusher/firebase credentials, or a custom transportFactory.
  • client.subscribe(channel, handler) / client.forUser(userId, handler) — subscribe; returns an unsubscribe function.
  • client.channelFor(userId) — the per-user channel name.
  • client.disconnect() — tear down the transport connection.
  • @arkstack/realtime/reactuseNotifications(client, channel, { limit? }){ notifications, latest, clear }.
  • @arkstack/realtime/vueuseNotifications(client, channel, { limit? }){ notifications, latest, clear, stop }.

See the notifications guide for the server side.

License

MIT