summaryrefslogtreecommitdiff
path: root/cli/bench/http/deno_reactdom_ssr_flash.jsx
blob: 0d749c634429de29b20f5bb16ca1e999c5ec4c53 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { renderToReadableStream } from "https://esm.run/react-dom/server";
import * as React from "https://esm.run/react";
const { serve } = Deno;
const addr = Deno.args[0] || "127.0.0.1:4500";
const [hostname, port] = addr.split(":");

const App = () => (
  <html>
    <body>
      <h1>Hello World</h1>
    </body>
  </html>
);

const headers = {
  headers: {
    "Content-Type": "text/html",
  },
};

serve(
  {
    fetch: async () => {
      return new Response(await renderToReadableStream(<App />), headers);
    },
    hostname,
    port,
  },
);