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.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.
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.Common commands
| Task | Command |
|---|---|
| Install dependencies | bun install |
| Start dev server | bun run dev |
| Build for production | bun run build |
| Start production server | bun run start |
| Run linter | bun run lint |
| Add a package | bun add <package> |
| Remove a package | bun remove <package> |
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.