Skip to content

Building a small web server in Deno with Pogo: routes, static files and JSX

Pogo is a small Deno web framework modelled on hapi. Route handlers return a value, such as a string, an object, a Response or a JSX element, and Pogo turns it into an HTTP response. It has a response toolkit (h) for files and redirects, and it renders React elements on the server without extra setup.

app.ts
import pogo from "https://deno.land/x/pogo@v0.6.0/main.ts";
const server = pogo.server({ port: 3000 });
server.router.get("/", () => {
return "Hello, Pogo!";
});
await server.start();
Terminal window
deno run --allow-net app.ts

Open http://localhost:3000. Create servers with the default export’s pogo.server() factory. The module has no Pogo export.

Pogo has no server.static(). Static files go through a route with a wildcard path parameter and the h.directory() toolkit method:

public/
style.css
server.router.get("/static/{file*}", (request, h) => {
return h.directory("public");
});

Pogo joins the directory with the last path parameter, so /static/style.css serves public/style.css. Directory listings are off by default. For a single file, use h.file("path/to/file"), which by default refuses paths outside the current working directory. Both read from disk, so add --allow-read.

Pogo doesn’t ship a template engine such as EJS. Instead, it renders React elements to static markup, so a handler can return JSX. Save this as app.tsx; the extension tells Deno to compile JSX:

app.tsx
import React from "https://esm.sh/react@18.2.0";
import pogo from "https://deno.land/x/pogo@v0.6.0/main.ts";
const server = pogo.server({ port: 3000 });
server.router.get("/static/{file*}", (request, h) => {
return h.directory("public");
});
server.router.get("/", () => {
const message = "Hello, Pogo!";
return (
<html lang="en">
<head>
<meta charSet="UTF-8" />
<title>Pogo Example</title>
<link rel="stylesheet" href="/static/style.css" />
</head>
<body>
<h1>{message}</h1>
</body>
</html>
);
});
await server.start();
Terminal window
deno run --allow-net --allow-read app.tsx

Import React from the same version Pogo uses internally (react@18.2.0 from esm.sh). Under Deno’s default classic JSX transform, <h1> compiles to React.createElement, so React has to be in scope. With React 19 you’d get elements that Pogo’s bundled React 18 renderer doesn’t recognise.

© 2026 David Li · Home · Blog · RSS ·Classic site · Built with Astro, Starlight and three.js · Logos:Font Awesome Free (CC BY 4.0)