// react-ssr.tsx import React from "react"; import { renderToPipeableStream } from "react-dom/server.node"; const http = require("http"); const App = () => (
This is an example.
); var didError = false; http .createServer(function (req, res) { const stream = renderToPipeableStream(Loading...
'); }, onAllReady() { // If you don't want streaming, use this instead of onShellReady. // This will fire after the entire page content is ready. // You can use this for crawlers or static generation. // res.statusCode = didError ? 500 : 200; // res.setHeader('Content-type', 'text/html'); // stream.pipe(res); }, onError(err) { didError = true; console.error(err); }, }); }) .listen(9080);