用途:帮助开发者在 Bun 运行时中运行 Next.js 应用,以获得更快的开发与构建体验,并指导在服务端代码中调用 Bun 原生 API。
主要能力:
- 用 bunx create-next-app@latest 创建项目,用 bun install 安装依赖;用 bun run dev / build / start 执行开发、构建与生产启动。
- 通过 --bun 标志(如 bun --bun next dev)强制 Next.js 使用 Bun 运行时而非 Node.js。
- 在服务端组件、API 路由、Server Actions 中使用 bun:sqlite、Bun.file、Bun.write 等 Bun API;相关包需在 next.config.js 的 serverExternalPackages 中声明(如 bun:sqlite)。
- Next.js 16 默认使用 Turbopack,webpack 配置不再支持;middleware.ts 更名为 proxy.ts,但部署到 Cloudflare via OpenNext 时应保留 middleware.ts。
- 提供 Docker 镜像(oven/bun:1)与 Vercel 部署方式。
使用方式要点:Bun 默认禁用 post-install 脚本,可在 package.json 的 trustedDependencies 中放行特定包;可在 bunfig.toml 中设置 minimumReleaseAge 冷却期;可用 socket 工具在安装前审计包。环境变量通过 .env.local 配置,客户端变量需以 NEXT_PUBLIC_ 前缀暴露。
限制:Vercel 边缘运行时使用 V8 而非 Bun,Bun API 仅在 Node.js 运行时的服务端组件、API 路由和 Server Actions 中可用;在 edge 运行时调用 Bun API 会报错。文档内容基于给出的技能资料,其余收费、价格等信息暂未提供。