Skip to main content

Streaming Rendering

Full Streaming Rendering is not supported by tramvai framework.

Streaming can significantly improve TTFB metric, but have a lot of disadvantages:

  • Require completely different framework architecture
  • Performance overhead for Streams (10-20% slower rendering time)
  • After first byte is sended, impossible to make server redirect or change response headers

For better new React 18 Suspense SSR features support, you can switch from renderToString to renderToPipeableStream API, with token REACT_SERVER_RENDER_MODE.

But with renderToPipeableStream tramvai will still buffer HTML before send it to client in one chunk. The main difference that we will waiting for Suspended components and render it at server-side. With renderToString opposite, we will render fallbacks only.

How to use renderToPipeableStream


Don't forget about performance penalty, renderToPipeableStream is slower than renderToString by 10-20%.

import { REACT_SERVER_RENDER_MODE } from '@tramvai/tokens-render';

const provider = provide({
useValue: 'streaming',