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: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: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 With this in place,
bun --bun so that all scripts run inside Bun’s runtime:package.json
bun run dev, bun run build, and bun run start all use Bun’s runtime.Common commands
Performance benefits
Using Bun as the package manager for Next.js projects provides:- Faster installs:
bun installis significantly faster thannpm installoryarn installdue 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.lockis committed to version control likepackage-lock.jsonoryarn.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.