nostrbasedocs
Start building
Guide
.md

Send and receive

const room = db.channel("editor", { broadcast: { self: true } });

room
  .on("broadcast", { event: "cursor" }, ({ payload, pubkey, sessionId }) => {
    console.log(payload, pubkey, sessionId);
  })
  .subscribe();

const { data, error, meta } = await room.send({
  type: "broadcast",
  event: "cursor",
  payload: { x: 120, y: 80 },
});
  • Use { event: "*" } to receive all broadcast event names.
  • Self delivery is off by default. Other sessions with the same signing key still receive messages.
  • A channel can subscribe and send without receive handlers.
  • A listener needs no signer. Sending requires an active signer.
  • data contains a write receipt. meta.relays records relay acknowledgements. The client’s minWriteAcks applies.
  • Payloads must contain JSON values. Duplicate events are ignored during their lifetime.

Delivery and privacy

  • Broadcast payloads and Presence state are public. Signing proves the author; it does not limit access.
  • Relays need not retain ephemeral events. The SDK does not put them in its event cache or offline write queue.
  • Relay acknowledgement proves acceptance, not delivery to every subscriber.
  • Presence is approximate. Disconnects, clock differences, dropped messages, or relay policies can delay joins and leaves.
  • Relays must accept and deliver kind 20078 and the channel tags. This is a nostrbase wire format, not a general Presence standard.
  • Negentropy recovers stored record events. It cannot recover ephemeral Broadcast or Presence history.

Search guides, API methods, and protocols.