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

@beignet/provider-broadcast-redis

v0.0.56

Published

Ephemeral redis broadcasting provider for Beignet

Readme

@beignet/provider-broadcast-redis

Redis Pub/Sub BroadcastPort provider for Beignet applications with multiple request instances or worker processes. It carries ephemeral browser update hints. Missed messages cannot be replayed; browsers must refetch after reconnect.

Install

bun add @beignet/core @beignet/provider-broadcast-redis ioredis zod

Beignet requires Node.js 22.12 or newer. Bun is also supported. This provider uses Node.js networking APIs and is not an Edge adapter. The example below uses Zod for channel schemas.

Configure the provider

import { createRedisBroadcastProvider } from "@beignet/provider-broadcast-redis";

export const providers = [createRedisBroadcastProvider()] as const;

Add this to your existing provider registry. Declare broadcast: BroadcastPort in AppPorts, importing the type from @beignet/core/broadcasting/server, and defer broadcast in infra/port-wiring.ts. The CLI can apply that wiring:

bun beignet provider add broadcast-redis
bun install

| Environment variable | Meaning | Default | | --- | --- | --- | | REDIS_BROADCAST_URL | Redis connection URL | Required | | REDIS_BROADCAST_PREFIX | Channel prefix unique to your app/environment | beignet:broadcast: | | REDIS_BROADCAST_CONNECT_TIMEOUT_MS | Connection and command deadline, 1–30,000 ms | 5000 |

Options { url, prefix, connectTimeoutMs, name } override the corresponding environment settings; name changes the lifecycle provider name. Use a rediss:// URL when your Redis deployment requires TLS. Every publisher and subscriber must use the same prefix. Redis Pub/Sub database numbers do not isolate channels; use separate prefixes and appropriate Redis access controls.

Direct use

import { defineChannel } from "@beignet/core/broadcasting";
import { createRedisBroadcast } from "@beignet/provider-broadcast-redis";
import { z } from "zod";

const changes = defineChannel("issues.changes", {
  params: z.object({ workspaceId: z.string() }),
  events: { changed: z.object({ issueId: z.string() }) },
});
const broadcast = createRedisBroadcast({
  url: "redis://localhost:6379",
  prefix: "my-app:development:broadcast:",
});
await broadcast.start();
const received = Promise.withResolvers<void>();
const subscription = broadcast.subscribe(changes, {
  params: { workspaceId: "workspace-1" },
  onEvent: event => {
    console.log(event.data.issueId);
    received.resolve();
  },
  onDisconnect: () => console.log("Reconnect and refetch"),
});
let timeout: ReturnType<typeof setTimeout> | undefined;
try {
  await subscription.ready;
  await broadcast.publish(changes, {
    params: { workspaceId: "workspace-1" },
    event: "changed",
    data: { issueId: "issue-1" },
  });
  await Promise.race([
    received.promise,
    new Promise<never>((_, reject) => {
      timeout = setTimeout(() => reject(new Error("No hint received")), 5_000);
    }),
  ]);
} finally {
  clearTimeout(timeout);
  try {
    await subscription.unsubscribe();
  } finally {
    await broadcast.close();
  }
}

Start a local Redis server before running this example. It waits up to five seconds to print issue-1 before shutting down; a successful publish() alone does not confirm that the listener ran. An application keeps its subscription until the owning component or process shuts down, and handles gaps by reconnecting and refetching authoritative state.

RedisBroadcast extends BroadcastPort with start() and close(). createRedisBroadcast requires url and accepts prefix, connectTimeoutMs, and instrumentation. The lifecycle provider starts and closes it for you.

Each instance shares a dedicated publisher/subscriber connection pair and reference-counts subscriptions to the same channel. Offline command queues, automatic subscription replay, and resending unfinished commands are disabled. Initial connection setup is bounded; failed provider startup closes both clients. Runtime connections may reconnect, but existing subscriptions report continuity loss and require fresh subscriptions. createBroadcastRoute closes affected SSE streams so browser clients reconnect and reconcile.

Publication resolves when Redis accepts the message, even with zero subscribers. It does not confirm browser delivery. Retries can duplicate hints. Schemas are validated before publishing and on receipt. Topic keys hash canonical channel identity; prefixes and hashes are not authorization boundaries.

Instrumentation uses the broadcast watcher for publications, failures, subscription lifecycle, malformed envelopes, and connection gaps. Records omit payloads, parameters, connection URLs, and origin IDs.

For required publication after a database mutation, record a publication job in the same transaction through an outbox and run it after commit. The outbox makes the publication attempt retryable; it does not make Redis subscribers durable.

Serverless deployment

Use a host that supports streaming HTTP responses and outbound Redis sockets. Configure SSE renewal below the host's request deadline with setup and cleanup headroom. Keep providers shared within an instance; do not create Redis clients for each channel or start a polling worker in a route module. Measure Redis connection counts and request memory/cost at your expected concurrency.

See the broadcasting guide for authorized channels, browser recovery, and deployment limits. For provider development, REDIS_TEST_URL=redis://localhost:6379 bun run test:live exercises independent connections and recovery after a real socket interruption.