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

@couch-kit/display

v0.4.0

Published

Browser display host for cross-network Couch Kit games — owns the authoritative runtime and bridges it to a game-agnostic relay

Downloads

248

Readme

@couch-kit/display

Browser display host for cross-network Couch Kit games. It owns the authoritative GameHostRuntime — exactly like the React Native GameHostProvider does on an Android TV — but bridges the runtime to a shared, game-agnostic relay server instead of a local LAN WebSocket. That lets phones on different networks join a game hosted in a browser tab.

 phone ─┐                       ┌─ RelayDisplayHost (owns the runtime)
 phone ─┼─ WebSocket ─▶ relay ◀─┘        browser display tab
 phone ─┘             (you deploy it)
  • The display owns the game; the relay only routes opaque envelopes by room code, so one relay deployment serves every game you build.
  • Framework-agnostic (no React dependency): subscribe with subscribe / getState from any UI, e.g. React's useSyncExternalStore.

Install

bun add @couch-kit/display @couch-kit/core @couch-kit/runtime @couch-kit/client

Usage

import { RelayDisplayHost } from "@couch-kit/display";
import { gameReducer, initialState } from "./shared"; // shared with the controller

const display = new RelayDisplayHost({
  url: "wss://your-relay.example.com", // YOUR relay — see note below
  roomId: "ABCD",
  reducer: gameReducer,
  initialState,
});

// Render whenever authoritative state changes.
display.subscribe(() => render(display.getState()));

Phones connect to the same room with the client's relay transport:

import { createRelayTransport } from "@couch-kit/client";

useGameClient({
  reducer: gameReducer,
  initialState,
  createTransport: createRelayTransport({
    url: "wss://your-relay.example.com",
    roomId: "ABCD",
  }),
});

API

new RelayDisplayHost(options)options is the game's GameHostRuntimeConfig (reducer, initialState, and the usual runtime knobs) plus the relay coordinates:

| Option | Description | | ----------- | ---------------------------------------------- | | url | WebSocket URL of your relay server | | roomId | Room code phones use to reach this display | | reducer | The shared game reducer | | initialState | The shared initial state |

Instance methods:

  • getState() — current authoritative state.
  • subscribe(listener) — subscribe to state changes; returns an unsubscribe fn.
  • dispatch(action) — dispatch a trusted host-side action.
  • stop() — tear down the runtime and close the relay socket.

The host maps relay PEER_JOINED / DATA / PEER_LEFT to the runtime's handleConnection / handleMessage / handleDisconnect, and implements the runtime's transport by wrapping outbound messages in relay DATA envelopes (unicast when addressed, room broadcast otherwise). Inbound phone messages are size-bounded (DEFAULT_MAX_MESSAGE_BYTES) before parsing.

Deploy your own relay — the SDK never points at anyone else's

The relay url is required config with no default. Couch Kit ships the relay as source you deploy yourself (services/relay), not a hosted service. Every game you build points at the relay you deploy; nobody consuming this SDK is routed through another developer's infrastructure. One relay deployment can serve all of your games — it is game-agnostic and keyed only by room code.