Bun Integration

hitlimit provides first-class support for Bun, the fast all-in-one JavaScript runtime. With Bun's native SQLite support and optimized performance, hitlimit achieves exceptional throughput for rate limiting in Bun applications.

Why Use hitlimit with Bun?

  • Native SQLite - Leverage Bun's built-in SQLite for zero-dependency persistent storage
  • Optimized Performance - Take advantage of Bun's speed with our optimized adapters
  • Bun.serve Integration - Direct integration with Bun's HTTP server
  • Elysia Plugin - First-class plugin for the Elysia framework

Quick Example

Rate limit a Bun.serve application in seconds:

server.ts
import { hitlimit } from '@joint-ops/hitlimit-bun'

const limiter = hitlimit({ limit: 100, window: '1m' })

Bun.serve({
  port: 3000,
  async fetch(req) {
    const result = await limiter.check(req)

    if (!result.allowed) {
      return new Response('Rate limited', { status: 429 })
    }

    return new Response('Hello from Bun!')
  }
})

Available Packages

For Bun applications, use the optimized package:

bun add @joint-ops/hitlimit-bun

This package includes Bun-specific optimizations and native SQLite store support.

Documentation