Quick start

Connect, subscribe and publish in about twenty lines. The example uses nostr-tools, but any NIP-01 client works.

Example

import { Relay } from "nostr-tools/relay";
import { finalizeEvent, generateSecretKey } from "nostr-tools/pure";

const sk = generateSecretKey();
const relay = await Relay.connect("wss://cinder-relay.cinderous1.workers.dev/app/my-game");

// Subscribe with a tag filter — no AUTH needed.
relay.subscribe([{ kinds: [1078], "#t": ["my-game-lobby"] }], {
  onevent(event) {
    console.log(event.pubkey, event.content);
  },
});

// Publish — also no AUTH needed.
await relay.publish(
  finalizeEvent(
    { kind: 1078, created_at: Math.floor(Date.now() / 1000), tags: [["t", "my-game-lobby"]], content: "hello" },
    sk,
  ),
);

What just happened

  • /app/my-game routed you into an app lane, not into the Cinderous messenger. The lane has its own storage.
  • The relay sent an AUTH challenge on connect. You can ignore it; it only matters for #p subscriptions (Authentication).
  • Kind 1078 is a regular event, so it is stored for a while and new subscribers will see it. Kinds 20000–29999 are only relayed live (Retention and storage).

Next steps