Add multiple users to the event stream subscription at once.
Each user can have an independent cursor position. If a user already exists, their cursor value is overwritten. Updates this builder and returns a copy for chaining. Rejected input leaves this builder unchanged.
Array of [z32PublicKey, cursor] tuples
Set maximum number of events to receive before closing the connection.
If omitted:
live=false: sends all historical events, then closeslive=true: sends all historical events, then enters live mode (infinite stream)Maximum number of events (1-65535)
Enable live streaming mode.
When called, the stream will:
Without this flag (default): Stream only delivers historical events and closes.
Note: Cannot be combined with reverse().
To stop a live stream, use the reader's cancel() method:
const stream = await pubky.eventStreamForUser(user, null).live().subscribe();
const reader = stream.getReader();
while (true) {
const { done, value } = await reader.read();
if (shouldStop) {
await reader.cancel(); // Closes the connection
break;
}
}
Set a client-side byte limit for SSE payloads. Unbounded by default. Limits accumulated data (including newlines joining data fields), each event name, and each ID separately in historical and live streams. Comments, unknown fields and framing bytes are excluded. There is no total block or stream byte limit. Overflow cancels the response and errors the ReadableStream. Updates this builder and returns a copy for chaining. Rejected input leaves this builder unchanged.
Integer in 1..=4294967295.
Filter events by path. Call once per path to receive the
union of several scopes (e.g. /pub/ plus a private /priv/app/).
Format: a path WITHOUT the pubky:// scheme or user pubkey. A trailing
slash matches a directory and all its descendants (/pub/files/); no
trailing slash matches an exact file (/pub/notes.txt).
Private (/priv/...) paths require a session attached via session();
without one the homeserver rejects the subscription with 401.
Path filter (repeatable)
Return events in reverse chronological order (newest first).
When called, events are delivered from newest to oldest, then the stream closes.
Without this flag (default): Events are delivered oldest first.
Note: Cannot be combined with live().
Authenticate the subscription with a user Session.
Required to receive private (/priv/...) events: the session credential
(grant or cookie) is attached so the homeserver can authorize each private
path() against the session's read capabilities. Public subscriptions
don't need this.
The authenticated session
Subscribe to the event stream.
This performs the following steps:
/events-stream URL with query parameters
Builder for creating an event stream subscription.
Construct via
Pubky.eventStreamForUser()orPubky.eventStreamFor(). Configuration methods consume this builder unless documented otherwise.Example
Example