// Master Bun runtime workflows for full-stack development. Monorepos, bunx, lockfiles, performance optimization, and integration patterns.
| name | bun-runtime |
| description | Master Bun runtime workflows for full-stack development. Monorepos, bunx, lockfiles, performance optimization, and integration patterns. |
| triggers | ["bun runtime","bunx","monorepo","bun workflows","bun performance","fast startup"] |
Leverage Bun's integrated toolkit for faster development. From one-off commands with bunx to optimizing monorepos, master the workflows that keep full-stack teams moving.
Bun is a complete toolkit in a single binary:
All in one. No configuration. No separate tools.
Replace globally installed CLI tools with bunx. Each command runs the latest version without cluttering your environment.
# โ Old way (npm)
npm install -g eslint
npx eslint .
# โ
New way (Bun)
bunx eslint .
bunx eslint --fix .
# Always uses latest version, no global pollution
# Create projects
bunx create-vite@latest my-app --template react-ts
bunx create-next-app@latest my-blog
# Run tools
bunx eslint . --fix
bunx prettier . --write
bunx tsc --noEmit
# Utilities
bunx tsx script.ts # Run TypeScript directly
bunx esbuild app.ts # Bundle app
bunx http-server . # Quick HTTP server
Define workspaces in root package.json for seamless monorepo management.
{
"name": "my-workspace",
"private": true,
"workspaces": [
"packages/*",
"apps/*",
"plugins/*"
]
}
my-workspace/
โโโ package.json # Root (defines workspaces)
โโโ packages/
โ โโโ core/ # Shared library
โ โ โโโ package.json
โ โ โโโ src/
โ โโโ utils/
โ โโโ package.json
โ โโโ src/
โโโ apps/
โ โโโ web/ # Next.js app
โ โ โโโ package.json
โ โ โโโ src/
โ โโโ mobile/ # React Native
โ โโโ package.json
โ โโโ src/
โโโ plugins/ # Claude Code plugins
โโโ my-plugin/
โ โโโ package.json
โ โโโ src/
Use workspace:* protocol for local dependencies:
{
"name": "@myapp/web",
"dependencies": {
"@myapp/core": "workspace:*",
"@myapp/utils": "workspace:*"
}
}
Benefits:
bun install in root# Install all dependencies
bun install
# Run script in specific workspace
bun --filter web run dev
# Run test in all workspaces with changes
bun test --recursive
# List workspaces
bun workspaces list
Bun creates a binary lockfile (bun.lockb) for fast, reliable builds.
# Generate lockfile
bun install
# Commit bun.lockb to git
git add bun.lockb
git commit -m "chore: update dependencies"
# CI: Install with frozen lockfile
bun install --frozen-lockfile
# Production: Skip dev dependencies
bun install --production
{
"dependencies": {
"react": "^18.2.0", // Patch updates ok
"typescript": "5.7.2" // Exact version (no updates)
}
}
# Bundle with default settings
bun build ./src/index.ts --outdir=./dist
# Minify and split chunks
bun build ./src/index.ts --minify --splitting
# Watch mode
bun build ./src/index.ts --watch
# Run all tests
bun test
# Run specific test file
bun test src/math.test.ts
# Watch mode (rerun on changes)
bun test --watch
# Coverage
bun test --coverage
No separate test runner needed. It's built in.
Bun has 4x faster startup than Node:
# Node.js
time node script.js
# real 0m0.345s
# Bun
time bun script.ts
# real 0m0.085s
[run]
logLevel = "error"
# Install all dependencies
bun install
# Run dev server for web app
bun --filter web run dev
# Run tests for changed packages
bun test --recursive
# Build everything
bun --filter "*" run build
# Create new CLI package
mkdir packages/my-cli
cd packages/my-cli
# Create package.json with bin entry
cat > package.json << EOF
{
"name": "@myapp/my-cli",
"bin": {
"my-cli": "./src/cli.ts"
},
"scripts": {
"test": "bun test"
}
}
EOF
# Back in root
bun install
# Test CLI from anywhere
bun my-cli --help
# scripts/deploy.ts (executable)
#!/usr/bin/env bun
import { $ } from "bun";
const env = process.env.NODE_ENV || "staging";
console.log(`Deploying to ${env}...`);
await $`git push origin main`;
await $`bun --filter web run build`;
await $`vercel deploy --prod`;
console.log("โ
Deployed!");
# Run it
chmod +x scripts/deploy.ts
./scripts/deploy.ts
# bunx create-next-app + Bun
bunx create-next-app@latest my-app --bun
cd my-app
# Next.js + Bun
bun run dev
bun run build
bun start
# Create Vite project
bunx create-vite@latest my-app --template react
cd my-app
# Use Bun
bun install
bun run dev
bun run build
# No configuration needed
bun run my-script.ts
# Watch mode
bun --watch src/index.ts
# Type checking (in CI)
bunx tsc --noEmit
npm inside a Bun project โ Use bun insteadworkspace:* for local depsbun install โ Faster, lockb is optimizedbunx โ For one-off commandsbun test โ Native, no config neededbun create or bunx to scaffoldbun install (creates bun.lockb).bunfig.toml if custom config neededbun.lockb to gitbun run for scriptsbun test for testingbunx for one-off tools| Task | Node.js | Bun |
|---|---|---|
| Startup | 0.3s | 0.08s |
| Install (100 packages) | 45s | 8s |
| Test run | 2.3s | 1.1s |
| Build (esbuild equiv.) | 1.5s | 0.4s |
Bun is 4-10x faster for typical full-stack workflows.
bun --help # All commands
bun install --help # Install options
bun run --help # Run options
bun test --help # Test options
Q: Is Bun production-ready? A: Yes, for most use cases. Check Bun's compatibility for your specific packages.
Q: Should I switch from Node.js? A: For new projects, yes. For existing, evaluate package compatibility first.
Q: Will my npm packages work? A: Most do. Bun is npm-compatible. Test critical dependencies first.
Q: How do I handle CI/CD with Bun?
A: Install Bun in CI, use bun install --frozen-lockfile, then bun run.
Q: Can I use Bun with monorepos? A: Absolutely. Workspaces make monorepos effortless.
Last Updated: 2025-12-05 Status: Reference Implementation Related: BUN_CLI_STANDARD.md, Bun Documentation