Purpose

Research on Bun runtime compatibility with NestJS framework, performance characteristics, and practical implementation patterns.

Documents

DocumentDescription
Bun Link CommandGuide to using bun link for local package development
tsconfig ResolutionFix for tsconfig path resolution when running from different directories
NotesGeneral 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 )
  • 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

  1. Initialize Project:

    Terminal window
    bun create bun-app --template api my-app
    cd my-app
  2. Add NestJS Dependencies:

    Terminal window
    bun add @nestjs/common @nestjs/core reflect-metadata
  3. 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();
  4. Run with Bun:

    Terminal window
    bun run main.ts

Performance Benchmarks

MetricBunNode.jsImprovement
Startup Time~50ms~100ms2x faster
Requests/sec~12.4k~10k+2.4k
Avg Latency~30ms~60ms50% 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

  1. How To Run NestJS with Bun - NooP Today
  2. Bun Compatibility with NestJS - Stack Overflow
  3. NestJS CLI Bun Support Issue - GitHub
  4. Bun Support Issue - GitHub
  5. Bun v1.0.3 Release - Bun Blog
  6. NestJS: Bun vs NodeJS - DEV Community
  7. Can Bun Run Any App Faster? - Medium

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

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.