Skip to main content
Next.js is a React framework for building full-stack web applications with server-side rendering, static site generation, API routes, and more. Bun speeds up package installation and script execution for Next.js projects.
Next.js still uses Node.js as its runtime for SSR and API routes. Bun acts as the package manager and script runner. Use bun --bun to run Next.js CLI commands inside Bun’s runtime.
1

Create a Next.js app

Scaffold a new Next.js project using Bun:
bun create next-app@latest my-bun-app
The interactive CLI will ask about TypeScript, ESLint, Tailwind CSS, and the App Router. Bun installs dependencies automatically after scaffolding.
2

Start the dev server

Change into the project directory and start the Next.js dev server with Bun’s runtime:
cd my-bun-app
bun --bun run dev
Open http://localhost:3000 in your browser. Changes to app/page.tsx are hot-reloaded automatically.
3

Update package.json scripts

Prefix the Next.js CLI commands with bun --bun so that all scripts run inside Bun’s runtime:
package.json
{
  "scripts": {
    "dev": "bun --bun next dev",
    "build": "bun --bun next build",
    "start": "bun --bun next start",
    "lint": "next lint"
  }
}
With this in place, bun run dev, bun run build, and bun run start all use Bun’s runtime.

Common commands

TaskCommand
Install dependenciesbun install
Start dev serverbun run dev
Build for productionbun run build
Start production serverbun run start
Run linterbun run lint
Add a packagebun add <package>
Remove a packagebun remove <package>

Performance benefits

Using Bun as the package manager for Next.js projects provides:
  • Faster installs: bun install is significantly faster than npm install or yarn install due to parallelism and a global package cache.
  • Faster script startup: Running Next.js CLI commands through Bun reduces the overhead of spawning child processes.
  • Lockfile compatibility: bun.lock is committed to version control like package-lock.json or yarn.lock.

Deployment

Next.js on Bun deploys to all major platforms:

Vercel

Deploy on Vercel

Railway

Deploy on Railway

AWS Lambda

Deploy on AWS Lambda

See the Next.js documentation for a complete reference on building and deploying Next.js applications.

Build docs developers (and LLMs) love