Deploy to Vercel
Run Vercel Functions on Bun via bunVersion, with Next.js steps and runtime differences
Last updated on
What you get
Vercel Functions execute requests with Bun — not just install dependencies with it. Works with supported frameworks (including Next.js) and standalone functions under /api.
1. Enable the Bun runtime
{
"$schema": "https://openapi.vercel.sh/vercel.json",
"bunVersion": "1.x"
}1.x is currently the only valid value; Vercel manages minor and patch versions. Don't pin a minor yourself.
2. The extra Next.js step
Next.js projects using ISR must hand dev / build to Bun:
{
"scripts": {
"dev": "bun run --bun next dev",
"build": "bun run --bun next build"
}
}The app is still bundled by Next.js's own pipeline (Turbopack/Webpack); --bun only changes which runtime executes the commands. Without ISR, confirm against current Vercel docs whether this step is still required.
3. Standalone functions
.ts files under /api compile and run as TypeScript directly:
export default {
async fetch(request: Request) {
const url = new URL(request.url);
const name = url.searchParams.get('name') || 'World';
return Response.json({ message: `Hello ${name}!` });
},
};Differences from the Node runtime
- No automatic source maps, no bytecode caching, and no request metrics on
node:http/node:https;fetchmetrics work on both runtimes. - Most Node.js APIs are supported, but not all; never start
Bun.serveinside a Function. - Routing Middleware behaves the same as on the Node runtime once
bunVersionis set, but the runtime config still saysnodejs.
Switching is reversible — test it anyway
Compare cold starts, p95, memory, and error rates on a preview deployment before cutting production over. Rolling back is deleting bunVersion. A stable Node workload doesn't need migrating for uniformity's sake.
Acceptance
- Preview function logs confirm Bun is active;
- SSR/ISR, streaming responses, Server Functions, and native-dependency paths are covered;
- Error stacks remain debuggable without automatic source maps;
- The metrics pipeline does not depend on
node:httprequest metrics.
Official references: Vercel Bun runtime, Bun on Vercel.