Example of Streaming Server-Side Rendering with Effect.ts

Hi. Is this how you do Streaming Server Side Rendering with Effect.ts?

  HttpRouter.get(
    '/',
    pipe(
      HttpServerRequest.HttpServerRequest,
      Effect.flatMap((req) =>
        pipe(
          Effect.tryPromise(() => renderToReadableStream(<App />)),
          Effect.map((body) => ({ req, body })),
        ),
      ),
      Effect.map(({ req, body }) =>
        HttpServerResponse.raw(body).pipe(
          HttpServerResponse.setHeader('Content-Type', 'text/html'),
        ),
      ),
    ),
  ),


It works, but I'm wondering if I did it right 🙂
Was this page helpful?