Skip to content

Deno

Deno is the open-source JavaScript runtime for the modern web.

  1. Follow the Node adapter guide

  2. Implement the serverEntrypoint using Deno APIs:

    src/server.ts
    import mod from "./handler";
    import sirv from "sirv";
    import { toFetchHandler } from "srvx/node"
    import { fileURLToPath } from "node:url";
    const server = Deno.serve({
    port: 3000,
    handler(request) {
    const response = toFetchHandler(sirv(fileURLToPath(new URL("../client/", import.meta.url)), {
    setHeaders: (res, pathname) => {
    if (pathname.startsWith("/assets/")) {
    res.setHeader("Cache-Control", "public, max-age=31536000, immutable");
    }
    },
    }))(request);
    if (response.status !== 404) {
    return response;
    }
    return mod.fetch(request);
    },
    });
    console.log("Ready at http://localhost:3000");
  3. After the build, run the server with deno run --allow-read --allow-net ./dist/server/index.mjs