aboutsummaryrefslogtreecommitdiff
path: root/bench/react-hello-world/react-hello-world.deno.jsx
blob: 0bea2574a29256ed62eaf77391d061a46ae145ee (plain) (blame)
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
import { renderToReadableStream } from "https://esm.run/react-dom/server";
import * as React from "https://esm.run/react";

const App = () => (
  <html>
    <body>
      <h1>Hello World</h1>
      <p>This is an example.</p>
    </body>
  </html>
);

const headers = {
  headers: {
    "Content-Type": "text/html",
    "Cache-Control": "no-transform", // disables response body auto compression, see https://deno.land/manual/runtime/http_server_apis#automatic-body-compression
  },
};

Deno.serve(
  async req => {
    return new Response(await renderToReadableStream(<App />), headers);
  },
  { port: 8080 },
);