Render ReadableStreams and async iterables
JSX children can be a ReadableStream or an async iterable: every item is streamed to the browser as soon as it is ready.
Items are rendered in order, and the markup rendered so far is sent while waiting for the next one.
ReadableStreams
A ReadableStream is rendered chunk by chunk, e.g. a streamed answer from an AI service or the decoded body of a fetch response. Its pull method is only called when the renderer wants the next chunk.
How does Jeasx render a ReadableStream?
ReadableStreams are rendered chunk by chunk as they arrive. This text comes from a ReadableStream which emits one word every 60 ms. Text chunks are escaped like any other string, so <b>this markup</b> shows up as plain text. A fetch response body works the same way: response.body.pipeThrough(new TextDecoderStream()).
Async iterables
A component written as async function* yields markup. It starts once the stream is done, as JSX renders in order. This is a natural fit for paginated APIs or database cursors: the next page is only loaded when the renderer needs it. If the browser stops loading the page, the generator is stopped like a for await loop on break, so its finally block runs and can release resources.
Releases
5 pages of 3, 700 ms per page| # | Release | Page | Flushed after |
|---|---|---|---|
| 1 | v1.0.0 | 1 / 5 | 3675 ms |
| 2 | v1.1.0 | 1 / 5 | 3675 ms |
| 3 | v1.2.0 | 1 / 5 | 3675 ms |
| 4 | v1.3.0 | 2 / 5 | 4375 ms |
| 5 | v1.4.0 | 2 / 5 | 4375 ms |
| 6 | v1.5.0 | 2 / 5 | 4375 ms |
| 7 | v1.6.0 | 3 / 5 | 5075 ms |
| 8 | v1.7.0 | 3 / 5 | 5076 ms |
| 9 | v1.8.0 | 3 / 5 | 5076 ms |
| 10 | v1.9.0 | 4 / 5 | 5776 ms |
| 11 | v1.10.0 | 4 / 5 | 5776 ms |
| 12 | v1.11.0 | 4 / 5 | 5776 ms |
| 13 | v1.12.0 | 5 / 5 | 6476 ms |
| 14 | v1.13.0 | 5 / 5 | 6476 ms |
| 15 | v1.14.0 | 5 / 5 | 6476 ms |