Render async iterables

Besides promises, JSX children can be async iterables, e.g. an async generator. Their items are rendered in order as they arrive. The markup rendered so far is sent to the browser while waiting for the next item.

A component can be an async function* which yields JSX. This is a natural fit for paginated APIs or database cursors: the next page is only loaded when the renderer needs it, and each page is streamed as soon as it is ready. 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.

Watch it again

Releases

5 pages of 3, 700 ms per page
#ReleasePageFlushed after
1v1.0.01 / 5702 ms
2v1.1.01 / 5702 ms
3v1.2.01 / 5702 ms
4v1.3.02 / 51404 ms
5v1.4.02 / 51404 ms
6v1.5.02 / 51404 ms
7v1.6.03 / 52105 ms
8v1.7.03 / 52105 ms
9v1.8.03 / 52106 ms
10v1.9.04 / 52806 ms
11v1.10.04 / 52806 ms
12v1.11.04 / 52806 ms
13v1.12.05 / 53508 ms
14v1.13.05 / 53508 ms
15v1.14.05 / 53508 ms
All done after 3508 ms