Streaming vs. string rendering

Jeasx streams JSX by default: the page shell is flushed immediately and slow parts follow as soon as they are ready. In v2, the complete markup was rendered to a string first and sent in one go.

Open the network tab of your browser's developer tools and reload the page in both modes. When streaming, the first byte arrives almost instantly, while the download keeps going until the last result is sent. When rendering to a string, the time to first byte equals the time of the slowest result, and the complete document arrives in one go.

The guard of this example shows how to restore the former string rendering in userland: it wraps this.jsxToString and calls jsxToString from jsx-async-runtime when a route sets this.jsxStream = false.

Streaming String

Current mode: streaming. Watch the results appear one after another.

Loading stock exchange...

Stock exchange

Result from stock exchange (took 500 ms)

rendered after 501 ms

Loading news feed...

News feed

Result from news feed (took 1000 ms)

rendered after 1000 ms

Loading weather service...

Weather service

Result from weather service (took 1500 ms)

rendered after 1500 ms

All done after 1500 ms.