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

@nicolaferraro/realtime-sdk

v0.1.0

Published

Realtime SDK for Redpanda

Readme

Redpanda Realtime SDK

A TypeScript SDK for real-time messaging with Redpanda.

Installation

npm install @nicolaferraro/realtime-sdk

Usage

Basic Example

import { Redpanda } from '@nicolaferraro/realtime-sdk';

// Create a client (default: http://localhost:8765)
const redpanda = new Redpanda();

// Or specify a custom URL
// const redpanda = new Redpanda('https://api.example.com');

// Get a channel
const channel = redpanda.channel('my-channel');

// Send data to the channel with a key
await channel.send('user-123', { message: 'Hello, World!' });

// Listen to events from the channel
const stopListening = await channel.listen((key, data) => {
  console.log('Key:', key);
  console.log('Data:', data);
});

// Stop listening when done
stopListening();

Sending Events

const channel = redpanda.channel('notifications');

// Send with a key
await channel.send('event-001', {
  event: 'user.login',
  userId: '123',
  timestamp: Date.now()
});

Listening to Events

const channel = redpanda.channel('events');

const stop = await channel.listen((key, data) => {
  console.log('Event key:', key);
  console.log('Event data:', data);
});

// Stop listening after 10 seconds
setTimeout(() => stop(), 10000);

Resuming from a Specific Key

The SDK supports resuming streams from a specific key, useful for recovering from disconnections:

const channel = redpanda.channel('events');

// Resume from the last processed key
const stop = await channel.listen(
  (key, data) => {
    console.log('Event:', key, data);
  },
  {
    lastKey: 'event-123', // Only receive events after this key
  }
);

The SDK automatically tracks the last received key and uses it for reconnection on failures.

Custom Error Handling

const channel = redpanda.channel('events');

const stop = await channel.listen(
  (key, data) => {
    console.log('Received:', key, data);
  },
  {
    onError: (error) => {
      // Custom error handling
      console.error('Channel error:', error);
      // The SDK will automatically retry with exponential backoff
    }
  }
);

API

Redpanda

The main client class.

Constructor

new Redpanda(baseUrl?: string)
  • baseUrl - Optional base URL (default: http://localhost:8765)

Methods

  • channel(name: string): RedpandaChannel - Get a channel interface

RedpandaChannel

Interface for interacting with a specific channel.

Methods

  • send(key: string, data: unknown): Promise<void> - Send data to the channel with a key
  • listen(callback: (key: string, data: unknown) => void, options?: ListenOptions): Promise<() => void> - Listen to events (returns a stop function)

ListenOptions

interface ListenOptions {
  lastKey?: string;      // Resume from events after this key
  onError?: (error: Error) => void;  // Custom error handler (defaults to console.error)
}

Features

Automatic Reconnection

The SDK automatically reconnects with exponential backoff (10ms to 10s) when connections are lost.

Stream Resumption

When reconnecting, the SDK automatically resumes from the last successfully received event, ensuring no events are missed.

Data Serialization

All data is automatically serialized to JSON when sending and deserialized from JSON when receiving.