Bun 2.0 has arrived with full Windows support and near-complete Node.js compatibility. It's now a serious contender for production workloads.
What's New in Bun 2.0
Native Windows Support
Finally, first-class Windows support:
# Install on Windows
powershell -c "irm bun.sh/install.ps1 | iex"
# Run your projects
bun run dev
99% Node.js Compatibility
Nearly all Node.js APIs now work:
fs,path,http,https✓child_process,worker_threads✓crypto(full OpenSSL compatibility) ✓- Native addons via N-API ✓
Performance Benchmarks
| Task | Node.js 22 | Bun 2.0 | Improvement |
|---|---|---|---|
| Startup | 40ms | 8ms | 5x faster |
| HTTP Server | 50k req/s | 150k req/s | 3x faster |
| File I/O | 1.2 GB/s | 3.6 GB/s | 3x faster |
| Install Deps | 15s | 2s | 7.5x faster |
Bun as a Complete Toolkit
Package Manager
# Install dependencies (faster than npm, yarn, pnpm)
bun install
# Add packages
bun add react next typescript
# Run scripts
bun run build
Bundler
// bun.build.ts
await Bun.build({
entrypoints: ['./src/index.tsx'],
outdir: './dist',
minify: true,
splitting: true,
sourcemap: 'external',
});
Test Runner
// math.test.ts
import { expect, test, describe } from 'bun:test';
describe('math', () => {
test('addition', () => {
expect(2 + 2).toBe(4);
});
});
bun test
SQLite Built-in
import { Database } from 'bun:sqlite';
const db = new Database('app.db');
db.run('CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY, name TEXT)');
const users = db.query('SELECT * FROM users').all();
Bun with Next.js
Bun now works seamlessly with Next.js:
# Create Next.js app with Bun
bun create next-app my-app
# Run development server
cd my-app
bun run dev
Hot Module Replacement
Bun's HMR is incredibly fast:
// React component with instant HMR
export function Counter() {
const [count, setCount] = useState(0);
return <button onClick={() => setCount(count + 1)}>{count}</button>;
}
// Changes reflect in <10ms
Macros
Compile-time code execution:
// config.ts
export const config = {
apiUrl: Bun.env.API_URL,
buildTime: new Date().toISOString(),
} as const;
// main.ts - config is inlined at build time
import { config } from './config' with { type: 'macro' };
console.log(config.buildTime); // Becomes a static string
Migration from Node.js
- Install Bun globally
- Replace
npm/yarn/pnpmwithbun - Replace
nodewithbun - Test thoroughly (some edge cases may differ)
Bun 2.0 is production-ready and worth considering for new projects and migrations.
Posted onjavascriptwith tags: