Docs

Guide 11

Runtime

11. Runtime

Bun is the default for everything that runs on your machine or in CI. Node is the deployed function runtime (D27).

Node stays supported everywhere, because the default must not become a requirement.


What M0 Verified

M0 verified Bun locally end to end under Bun 1.3.14 with Next 16.2.12. These all passed:

  • bun run --bun next build
  • production serving
  • routing middleware
  • ISR revalidation

Bun as the Vercel function runtime couldn't be verified against a live deployment. So it's an opt-in instead of the default until it is.


The Matrix

StageRuntimeHow
installBunzero-config on Vercel
devBunbun run --bun next dev
buildBunbun run --bun next build
function runtimeNodeVercel default, no config
function runtime, opt-inBun{"bunVersion": "1.x"} in vercel.json
middlewareNodeNext 16 Proxy defaults to the Node runtime
testsBunbun test
CLIBunnative TypeScript, no transpile step, compiles to a single binary

Verify the opt-in Bun function runtime on a preview first.

Shipped Files

vercel.json ships with only the schema. Add "bunVersion": "1.x" to opt in to the Bun function runtime.

// vercel.json
{
  "$schema": "https://openapi.vercel.sh/vercel.json"
}
// package.json
{
  "scripts": {
    "dev": "reeve route:sync && bun run --bun next dev",
    "build": "reeve route:sync && bun run --bun next build",
    "test": "bun test",
    "check": "reeve doctor"
  }
}

Known Gaps on the Bun Runtime

  • No automatic source maps
  • No bytecode caching
  • No request metrics on node:http and node:https. Metrics via fetch work on both runtimes

None of these block v1. All 3 are worth stating in the docs, because "my stack traces got worse" is a support ticket you can prevent with one sentence.


Why Bun

  • Native TypeScript execution. The CLI and generators have no transpile step and no tsx dependency
  • bun build --compile produces a single-binary CLI, so reeve installs without a Node toolchain
  • bun test is fast enough to run on save, which is the only property that decides whether tests actually get written
  • Install speed matters in CI when every package installs from a cold cache

The Constraint

**@avelonjs/core and @avelonjs/orm may never import bun:*.** The Bailiff rule no-bun-in-core enforces it.

3 reasons:

  1. A self-hoster running Node must be able to use this.
  2. Adapters other than Next may target runtimes where Bun isn't available.
  3. The day Bun and a deployment platform disagree about something you need, you want an exit that's a configuration change instead of a rewrite.

Bun-specific code is allowed in:

  • @avelonjs/cli, which always runs locally or in CI
  • driver packages. The ones that need Bun are listed under Node Fallback

Node Fallback

The fallback is Node 22 or later, with tsx for the CLI. It's slower, and it's supported.

These drivers import Bun's SQL client, so they don't load on Node:

  • @avelonjs/postgres
  • the @avelonjs/neon queue and token drivers

CI runs the suite on Bun 1.3.14 only. No job runs it on Node.