README
Purpose
Research on Bun runtime compatibility with NestJS framework, performance characteristics, and practical implementation patterns.
Documents
| Document | Description |
|---|---|
| Bun Link Command | Guide to using bun link for local package development |
| tsconfig Resolution | Fix for tsconfig path resolution when running from different directories |
| Notes | General implementation notes and observations |
Key Findings
- Full Compatibility: Bun fully supports NestJS as of v1.0.3 (September 2023) with decorator metadata support
- Performance: ~2x faster startup and ~2.4k more requests/sec compared to Node.js
- Latency: ~30ms average latency improvement over Node.js
- Decorator Support: emitDecoratorMetadata is now supported, enabling dependency injection and decorators
- Edge Cases: Some packages may have edge case issues, but core NestJS packages work well
- No Transpilation: Bun can run TypeScript directly without pre-compilation
- CLI Support: NestJS CLI doesn’t have first-class Bun support yet (open GitHub issue #13881)
- Starter Templates: Community starter templates available (bunest, bun-nest-starter, bun-nestjs)
Current Status
✅ Fully Compatible - NestJS works out-of-the-box with Bun runtime
What Works
- Core NestJS framework and features
- Dependency injection via decorators
- TypeScript execution without compilation
- Database connections and ORMs
- HTTP routing and controllers
- Middleware and guards
Known Limitations
- Some third-party packages may have compatibility issues
- NestJS CLI tools don’t detect/prefer Bun runtime
- Type-checking must be done separately (Bun doesn’t type-check at runtime)
- Not all optional dependencies handle missing gracefully
- tsconfig resolution issue when running from different directory - see tsconfig-resolution.md
Implementation Guide
Quick Start
-
Initialize Project:
Terminal window bun create bun-app --template api my-appcd my-app -
Add NestJS Dependencies:
Terminal window bun add @nestjs/common @nestjs/core reflect-metadata -
Create main.ts:
import { NestFactory } from '@nestjs/core';import { AppModule } from './app.module';async function bootstrap() {const app = await NestFactory.create(AppModule);await app.listen(3000);}bootstrap(); -
Run with Bun:
Terminal window bun run main.ts
Performance Benchmarks
| Metric | Bun | Node.js | Improvement |
|---|---|---|---|
| Startup Time | ~50ms | ~100ms | 2x faster |
| Requests/sec | ~12.4k | ~10k | +2.4k |
| Avg Latency | ~30ms | ~60ms | 50% faster |
Community Resources
- bunest: Full-featured NestJS starter with Bun (GitHub: dung204/bunest)
- bun-nest-starter: Modern starter with Drizzle ORM (GitHub: Netoun/bun-nest-starter)
- bun-nestjs: Simple NestJS + Bun starter (GitHub: letstri/bun-nestjs)
Sources
- How To Run NestJS with Bun - NooP Today
- Bun Compatibility with NestJS - Stack Overflow
- NestJS CLI Bun Support Issue - GitHub
- Bun Support Issue - GitHub
- Bun v1.0.3 Release - Bun Blog
- NestJS: Bun vs NodeJS - DEV Community
- Can Bun Run Any App Faster? - Medium
Related Research
Discovered through cross-reference analysis (semantic similarity + shared technologies):
High Relevance (Score 100+)
- claude-code - Development environment research; shared focus on TypeScript, Bun performance, and developer tooling
- agents - Multi-platform agent architecture patterns; overlaps with NestJS as framework for building agent systems, shared TypeScript/Node ecosystem
Strong Relevance (Score 60-95)
- zig-programming-language - Performance-focused language research; shares interest in runtime performance characteristics like Bun
- duckdb - Database technology research; NestJS + Bun applications often use DuckDB for analytics/embedded databases
- claude-code-agents - Agent implementation patterns; relevant for building NestJS-based agent frameworks
Related Ecosystems (Score 60)
- ubuntu-audio-streaming - Media streaming architecture; potential use case for Bun/NestJS applications
- chromecast-audio-ubuntu - Device communication patterns; relevant for IoT/audio streaming NestJS projects
Last updated: 2025-11-24
Additional Notes
Cross-reference discovery through find-related tool demonstrates effective semantic analysis for finding related research topics in knowledge base. The results can be automatically formatted and integrated into documentation.