Skip to content

react-dom/server: clarify when renderToPipeableStream is appropriate #4510

@isker

Description

@isker

At https://reactjs.org/docs/react-dom-server.html#rendertopipeablestream we see this note:

This is a Node.js specific API and modern server environments should use renderToReadableStream instead.

I initially read this as saying "use renderToReadableStream in any environment where web streams are available." This includes modern versions of Node: https://nodejs.org/api/webstreams.html.

But going to the main React 18 release notes page https://reactjs.org/blog/2022/03/29/react-v18.html#react-dom-server, we see that there is a different distinction being made.

renderToPipeableStream: for streaming in Node environments.
renderToReadableStream: for modern edge runtime environments, such as Deno and Cloudflare workers.

(Aside: is Deno really an "edge runtime environment"? 🤔 )

Combined with @sebmarkbage's outlining of the downsides of web streams here reactwg/react-18#91, it seems clear that renderToPipeableStream should always be preferred in Node environments. It'd be nice if the docs clearly spelled this out.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions