Skip to content

Getting Started

  1. Terminal window
    bun add -D next-bun-compile
  2. next-bun-compile is a Next.js Build Adapter. Add adapterPath to your next.config.ts:

    import type { NextConfig } from "next";
    const nextConfig: NextConfig = {
    adapterPath: "next-bun-compile",
    };
    export default nextConfig;

    No output: "standalone" needed — the adapter assembles its own traced output tree. You can also enable it without touching the config at all:

    Terminal window
    NEXT_ADAPTER_PATH=next-bun-compile next build
  3. Terminal window
    next build

    One command. Produces a single ./server executable next to your package.json.

  4. Terminal window
    ./server

    Listens on port 3000 by default. Configurable via the PORT env var.

Three changes:

  1. Remove output: "standalone" from next.config.ts and add adapterPath: "next-bun-compile".
  2. Change your build script from next build && next-bun-compile to just next build.
  3. Cross-compiling? --target=bun-linux-x64 becomes NBC_TARGET=bun-linux-x64 next build.
  • Your Next.js server runtime (chunks, manifests, build ID)
  • Static assets (.next/static/*) and public files (public/*)
  • Prerendered pages and their RSC payloads
  • All externalized server packages (sharp, prisma, anything in serverExternalPackages, etc.)
  • The bun runtime itself (you don’t need bun on the deploy target)

At runtime, static assets and fully-static prerendered pages are served directly from memory; ISR and cache-component responses get an in-memory cache that Next’s own revalidation invalidates. The binary extracts its server runtime files to disk on first run (or to NBC_RUNTIME_DIR — point it at tmpfs for read-only filesystems), and skips extraction on subsequent runs of the same build.

Terminal window
PORT=3000 ./server &
curl http://localhost:3000/

You should see your homepage HTML. From here, the typical next step is putting it in a Docker image — see the Distroless + sharp recipe for a complete working Dockerfile.