Skip to content

feat(res): add res.sse() for Server-Sent Events#1

Merged
danelmott merged 1 commit into
masterfrom
feature-sse
Jun 29, 2026
Merged

feat(res): add res.sse() for Server-Sent Events#1
danelmott merged 1 commit into
masterfrom
feature-sse

Conversation

@danelmott

Copy link
Copy Markdown
Owner

Add a res.sse() helper that opens a text/event-stream response and returns a stream with send(), stream(), comment() and close().

send() serializes data like the rest of the framework (strings as-is, Buffer/TypedArray as UTF-8, objects as JSON) and supports event/id/retry. stream() emits one event per chunk of any web ReadableStream, Node Readable, Blob or async iterable, unifying them into a Node Readable (web streams and Blobs via Readable.fromWeb(), Node streams and async iterables directly).

A keep-alive heartbeat is started by default and cleared automatically on disconnect via on-finished. No new dependencies are added.

Add a res.sse() helper that opens a text/event-stream response and returns a
stream with send(), stream(), comment() and close().

send() serializes data like the rest of the framework (strings as-is,
Buffer/TypedArray as UTF-8, objects as JSON) and supports event/id/retry.
stream() emits one event per chunk of any web ReadableStream, Node Readable,
Blob or async iterable, unifying them into a Node Readable (web streams and
Blobs via Readable.fromWeb(), Node streams and async iterables directly).

A keep-alive heartbeat is started by default and cleared automatically on
disconnect via on-finished. No new dependencies are added.
@danelmott
danelmott merged commit 614a168 into master Jun 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant