NOTICE: 2021/04/09 no longer hosts typescript files. Use

Use JSX as a template

Deno has a built-in JSX support powered by TypeScript.

By default, JSX files (.jsx, .tsx) will be transformed by React.createElement(). So you must import React on the head of your jsx file.

React is developed in Node.js and Browser ecosystem and there are no official ESM-based distribution. We recommend you get React for deno from, which is ESModule CDN for CommonJS.

React is written by pure JavaScript and has no type definition by default. Optionally, you can use type definitions for React by annotating import statement with @deno-types. This is Deno's extension method for mapping JavaScript file and type definition. You can find more detail information on the official manual.

Unfortunately, there are no pure ESM type definitions for React 😇. So we are providing patched type definitions for Deno.

Here is the most essential example to use JSX with Servest.

// @deno-types="[email protected]/types/react/index.d.ts"
import React from "";
// @deno-types="[email protected]/types/react-dom/server/index.d.ts"
import ReactDOMServer from "";
import { createApp } from "[email protected]/mod.ts";

const app = createApp();
app.handle("/", async (req) => {
  await req.respond({
    status: 200,
    headers: new Headers({
      "content-type": "text/html; charset=UTF-8",
    body: ReactDOMServer.renderToString(
          <meta charSet="utf-8" />
        <body>Hello Servest!</body>
app.listen({ port: 8899 });