React renderToReadableStream
I'm trying to figure out how to create a simple Rust HTTP backend and implement server-side rendering in it. Currently, I'm just calling code that returns HTML as follows:
This is a snippet from my javascript code which is executed using rquickjs and llrt modules:
const handler = async () => {
const app = ReactDOMServer.renderToString(React.createElement(<Page/>));
const html = `<div id="root">${app}</div>`;
return html;
};I don't think this is ideal for handling high traffic because I'm seeing strange errors from QuickJS, which I assume are due to the cost of renderToString. I'm wondering if exposing the ReadableStream struct from the web-stream module would allow me to leverage streaming in Rust and serve responses directly from my Rust HTTP application.
What do you think? What are the possible solutions for achieving this? Or am I completely off-track in my approach to SSR using the web-stream module in a Rust HTTP server?
Source: awslabs/llrt