Skip to main content

Deploy a Bun application on Vercel

还没翻译译自英文(bun.com)本页 25 段都还没译

Vercel is a cloud platform for building, deploying, and scaling apps. Vercel Functions can run on the Bun runtime, either behind a framework that Vercel supports or as a Bun.serve() server.

Warning

Automatic source maps, bytecode caching, and request metrics for node:http and node:https are not supported on the Bun runtime (request metrics for fetch are). See feature support in the Vercel documentation.


  1. Configure Bun in vercel.json

    To run your Functions on Bun, add a bunVersion field to your vercel.json file:

    {
    	"bunVersion": "1.4.x"
    }

    Vercel manages the patch version.

    For best results, match your local Bun version with the version Vercel uses.

  2. Add a server

    Choose how requests reach your code.

    Bun.serve() for the whole appBun.serve() under /apiNext.js or another framework

    Vercel's Bun framework preset sends every request for the deployment to a single Bun.serve() server. Vercel uses the preset when the project sets bunVersion, has a bun.lock file, and has a server entrypoint at one of these paths:

    • server.{js,cjs,mjs,ts,cts,mts}
    • src/server.{js,cjs,mjs,ts,cts,mts}

    bun install creates bun.lock on Bun 1.2 or later. On older versions, run bun install --save-text-lockfile. The preset does not detect the binary bun.lockb format.

    Call Bun.serve() once while the module loads. Vercel detects that call and routes incoming requests to it. Vercel supports the fetch, routes, error, and websocket options:

    Bun.serve({
    	routes: {
    		"/health": () => Response.json({ status: "ok" }),
    	},
    	fetch() {
    		return new Response("Hello from Bun on Vercel");
    	},
    });

    A minimal project is package.json, bun.lock, server.ts, and the vercel.json from the previous step. It doesn't need an api/ directory or any routing configuration.

    Note

    port and hostname only apply when you run the server locally; they don't configure the deployed endpoint. Unix sockets and HTML imports in routes are not supported on Vercel.

    To serve WebSocket connections, see the Bun example in Vercel's WebSockets documentation.

  3. Deploy your app

    Connect your repository to Vercel, or deploy from the CLI:

    # Using bunx (no global install)
    bunx vercel login
    bunx vercel deploy

    Or install the Vercel CLI globally:

    bun i -g vercel
    vercel login
    vercel deploy

    Learn more in the Vercel Deploy CLI documentation →

  4. Verify the runtime

    To confirm your deployment uses Bun, log the Bun version:

    console.log("runtime", process.versions.bun);
    runtime 1.4.0

    See the Vercel Bun Runtime documentation for feature support →


  • Fluid compute: Both Bun and Node.js runtimes run on Fluid compute and support the same core Vercel Functions features.
  • Middleware: To run Routing Middleware with Bun, set the runtime to nodejs:
export const config = { runtime: "nodejs" };
번역 © 2026 fanyi.dev · 원문 © 2026 the Bun project (LICENSE.md names no copyright holder) (MIT)