Skip to content

Bun

Bun is a fast, incrementally adoptable all-in-one JavaScript, TypeScript & JSX toolkit.

  1. Check Bun’s Vite guide

  2. Follow the Node adapter guide

  3. Implement the serverEntrypoint using Bun APIs:

    src/server.ts
    import mod from "./handler";
    import * as http from "node:http";
    import sirv from "sirv";
    import { toFetchHandler } from "srvx/node"
    import { fileURLToPath } from "node:url";
    const server = Bun.serve({
    port: 3000,
    fetch(request) {
    const response = toFetchHandler(sirv(fileURLToPath(new URL("../client/", import.meta.url)), { dev: true }))(request);
    if (response.status !== 404) {
    return response;
    }
    return mod.fetch(request);
    },
    });
    console.log("Ready at http://localhost:3000");
  4. After the build, run the server with bun ./dist/server/index.mjs