Skip to main content
Vercel is a cloud platform for deploying and scaling web applications.
The Bun runtime on Vercel is in Beta. Certain features — such as automatic source maps, byte-code caching, and metrics on node:http/https — are not yet supported.
Bun.serve is not supported on Vercel Functions. Use Bun with a framework supported by Vercel, such as Next.js, Express, Hono, or Nitro.
1

Configure Bun in vercel.json

To enable the Bun runtime for your Vercel Functions, add a bunVersion field to your vercel.json:
vercel.json
{
  "bunVersion": "1.x"
}
Vercel automatically detects this configuration and runs your functions on Bun. The value must be "1.x" — Vercel manages the minor version internally. For best results, match your local Bun version with the version used by Vercel.
2

Set Bun as the package manager (optional)

To ensure Vercel uses Bun to install dependencies, set packageManager in package.json:
package.json
{
  "packageManager": "bun@1.x"
}
Alternatively, add ENABLE_BUN_INSTALL=1 as an environment variable in the Vercel dashboard.
3

Configure Next.js scripts (if applicable)

If you are deploying a Next.js project, update your package.json scripts to use the Bun runtime by prefixing Next.js CLI commands with bun --bun:
package.json
{
  "scripts": {
    "dev": "bun --bun next dev",
    "build": "bun --bun next build",
    "start": "bun --bun next start"
  }
}
The --bun flag runs the Next.js CLI under Bun’s runtime. Bundling (via Turbopack or Webpack) is unchanged, but all lifecycle commands execute within Bun.
4

Set environment variables

Configure environment variables in the Vercel dashboard under Project Settings → Environment Variables, or via the CLI:
vercel env add DATABASE_URL
vercel env add API_SECRET
Access them at runtime using process.env or Bun.env:
const dbUrl = process.env.DATABASE_URL;
const secret = Bun.env.API_SECRET;
5

Deploy your app

Connect your repository to Vercel via the dashboard, or deploy from the CLI using bunx:
# Using bunx (no global install required)
bunx vercel login
bunx vercel deploy
Or install the Vercel CLI globally with Bun:
bun i -g vercel
vercel login
vercel deploy
6

Verify the runtime

To confirm your deployment is running on Bun, log the runtime version:
index.ts
export default function handler(req: Request) {
  return new Response(`Running on Bun ${process.versions.bun}`);
}
The response should read something like Running on Bun 1.3.3.

Serverless function example

Here is an example Vercel Function using Bun’s native Request/Response API:
api/hello.ts
export default function handler(req: Request) {
  const url = new URL(req.url);
  const name = url.searchParams.get("name") ?? "World";
  return new Response(`Hello, ${name}!`);
}

Additional notes

  • Fluid compute: Both Bun and Node.js runtimes run on Vercel’s Fluid Compute and support the same core Vercel Functions features.
  • Middleware: Routing Middleware must use the nodejs runtime:
middleware.ts
export const config = { runtime: "nodejs" };
See the Vercel Bun Runtime documentation for the full feature support matrix.

Build docs developers (and LLMs) love