Convert a ReadableStream to a String in JavaScript
I have recently come across the need to convert a ReadableStream to a String. In my case this was because I was using React’s react-dom/server to render a component in an edge worker. More specifically, I needed to build an email body from ReMirror JSON content using their static renderer.
Using ReactDOMServer.renderToReadableStream.
The renderToReadableStream method is the only option for rendering React DOM in a modern edge environment. That’s ok, it’s not hard to use a reader to build a string, chunk by chunk.
Dave Taylor - Software Engineer