Skip to main content

Stream JSON Lines

Use StreamingHelper.streamJsonLines when a dataset is too large to load all at once.
fetchSSE is a fetch-based SSE consumer that supports any HTTP method, request bodies, AbortSignal, multiple event types, and returns an AsyncGenerator so you can use for await … of.
Use fetchSSE instead of streamSSE whenever you need POST requests, request bodies, cancellation, or multiple event types. streamSSE (EventSource-based) remains available for simple GET-only SSE.

POST with body and cancellation

Filter by event type

Pass eventTypes to restrict which SSE event types are yielded. Omit it to receive all events.

Legacy SSE with streamSSE

For simple GET endpoints where you don’t need POST, body, or for await, the EventSource-based API still works:

Track streamed downloads

When to use which method

Best practices

  • Use fetchSSE for any SSE endpoint that requires POST or cancellation.
  • Pass an AbortSignal to cancel long-lived streams when components unmount.
  • Set explicit timeouts for long-lived streams.
  • Process chunks incrementally if the dataset is large.
  • Filter with eventTypes to ignore keep-alive or debug events you don’t need.