Bun.serve is not supported on Vercel Functions. Use Bun with a framework supported by Vercel, such as Next.js, Express, Hono, or Nitro.Configure Bun in vercel.json
To enable the Bun runtime for your Vercel Functions, add a Vercel automatically detects this configuration and runs your functions on Bun. The value must be
bunVersion field to your vercel.json:vercel.json
"1.x" — Vercel manages the minor version internally. For best results, match your local Bun version with the version used by Vercel.Set Bun as the package manager (optional)
To ensure Vercel uses Bun to install dependencies, set Alternatively, add
packageManager in package.json:package.json
ENABLE_BUN_INSTALL=1 as an environment variable in the Vercel dashboard.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
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.Set environment variables
Configure environment variables in the Vercel dashboard under Project Settings → Environment Variables, or via the CLI:Access them at runtime using
process.env or Bun.env:Deploy your app
Connect your repository to Vercel via the dashboard, or deploy from the CLI using Or install the Vercel CLI globally with Bun:
bunx:Serverless function example
Here is an example Vercel Function using Bun’s nativeRequest/Response API:
api/hello.ts
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
nodejsruntime:
middleware.ts