Powered by Bun's Native Performance

0http-bun

The fastest way to build HTTP services with Bun. Zero config, maximum performance.

Why Choose 0http-bun?

Built for developers who demand performance without sacrificing developer experience

🚀

Bun-Native Performance

Optimized specifically for Bun's runtime with minimal overhead. Direct use of Web APIs and efficient routing based on the proven trouter library delivers sub-millisecond request handling.

🔧

TypeScript First

Full TypeScript support with comprehensive type definitions for all APIs. Enjoy excellent IDE autocomplete, type safety, and inline documentation as you build.

🎯

Minimalist API

Clean, intuitive API inspired by Express but built for modern runtimes. Get started in seconds without sacrificing power, flexibility, or performance.

🔄

Rich Middleware Ecosystem

Flexible async/await middleware system. Built-in support for CORS, JWT auth, rate limiting, body parsing, Prometheus metrics, and structured logging. Optional dependencies keep your bundle lean.

📦

Tiny Footprint

Lightweight framework with minimal dependencies and intelligent caching. Memory-efficient design with route caching and object reuse to minimize allocations and maximize throughput.

🛡️

Web Standards Built-in

Built entirely on standard Web APIs (Request/Response). Write portable code that works across Bun, Deno, Cloudflare Workers, and other modern runtimes. No vendor lock-in.

Get Started in Seconds

Production-ready HTTP server with full TypeScript support and middleware

server.ts
// Install: bun add 0http-bun
import http, { ZeroRequest, StepFunction } from '0http-bun'
import { createCORS, createLogger, createRateLimit } from '0http-bun/lib/middleware'

// Create router with error handling
const {router} = http({
  errorHandler: (err: Error) => Response.json({error: err.message}, {status: 500})
})

// Apply middleware stack
router.use(createCORS())          // CORS support
router.use(createLogger())        // Request logging
router.use(createRateLimit({max: 100}))  // Rate limiting

// Define routes with full type safety
router.get('/api/users/:id', async (req: ZeroRequest) => {
  return Response.json({ 
    id: req.params.id,
    name: 'John Doe'
  })
})

router.post('/api/users', async (req: ZeroRequest) => {
  const body = await req.json()
  return Response.json({created: true, data: body}, {status: 201})
})

// Start server
Bun.serve({ port: 3000, fetch: router.fetch })

Comprehensive Middleware Suite

Production-ready middleware for common use cases. Install only what you need.

📝

Body Parser

Automatic parsing of JSON, form data, and text payloads with configurable size limits and error handling.

🌐

CORS

Flexible Cross-Origin Resource Sharing with support for credentials, custom headers, and preflight caching.

🔐

JWT Authentication

Secure JSON Web Token authentication with role-based authorization, token validation, and custom claims support.

📊

Prometheus Metrics

Export HTTP metrics for monitoring and alerting. Track request rates, latencies, and error rates out of the box.

⏱️

Rate Limiting

Flexible rate limiting with sliding window support. Protect your APIs from abuse with customizable limits per IP or key.

📋

Logger

Structured request logging with multiple output formats. Built on Pino for high-performance logging in production.

Built for Modern Web

Leveraging Bun's speed with developer-friendly APIs

Sub-ms Routing
🎯
Zero Config
💯
100% TypeScript
🌐
Web Standards

Ready to Get Started?

Build high-performance HTTP services with Bun today

Read the Documentation