Covers the essentials of Bun.serve() for building HTTP servers without needing external frameworks. You get request/response handling, body parsing for JSON and forms, simple regex-based routing patterns, static file serving, and CORS setup. The examples are practical and show you how to handle common scenarios like error handling, different response types, and server configuration options. If you're building a REST API or simple web server with Bun and want to stick with the standard library instead of pulling in Express or Hono, this gives you the patterns to do it. The routing approach is basic but functional for small to medium projects.

skills.sh installs
336
GitHub stars
248
last updated
Aug 21, 2026

Install

$ npx -y skills add secondsky/claude-skills --skill bun-http-server --agent claude-code

Installs into .claude/skills of the current project.

Files

Bun HTTP Server

Bun has a built-in high-performance HTTP server via Bun.serve().

Quick Start

const server = Bun.serve({
  port: 3000,
  fetch(req) {
    return new Response("Hello World!");
  },
});

console.log(`Server running at http://localhost:${server.port}`);

Request Handling

Bun.serve({
  fetch(req) {
    const url = new URL(req.url);

    // Method
    console.log(req.method); // GET, POST, etc.

    // Path
    console.log(url.pathname); // /api/users

    // Query params
    console.log(url.searchParams.get("id")); // ?id=123

    // Headers
    console.log(req.headers.get("Content-Type"));

    return new Response("OK");
  },
});

Body Parsing

Bun.serve({
  async fetch(req) {
    // JSON
    const json = await req.json();

    // Form data
    const form = await req.formData();

    // Text
    const text = await req.text();

    // ArrayBuffer
    const buffer = await req.arrayBuffer();

    // Blob
    const blob = await req.blob();

    return new Response("Received");
  },
});

Response Types

Bun.serve({
  fetch(req) {
    const url = new URL(req.url);

Sponsors

Details

Repository
github.com/secondsky/claude-skills
Category
Backend & APIs
First seen
Jun 3, 2026

More from secondsky/claude-skills

All 146
1jezweb avatarazure-authjezweb/claude-skillsMicrosoft Entra ID (Azure AD) authentication for React SPAs with MSAL.js and Cloudflare Workers JWT validation using jose library. Full-stack pattern with Autho327skills.sh installs
2patricio0312rev avatarqueue-job-processorpatricio0312rev/skillsImplements background job processing with BullMQ/Redis including job queues, workers, scheduling, retries, and monitoring. Use when users request "background jo295skills.sh installs
3patricio0312rev avatarapi-security-hardenerpatricio0312rev/skillsHardens API security with rate limiting, input validation, authentication, and protection against common attacks. Use when users request "API security", "secure284skills.sh installs
4pedronauck avatarbetter-auth-best-practicespedronauck/skillsSkill for integrating Better Auth - the comprehensive TypeScript authentication framework.281skills.sh installs
5whoamihappyhacking avatarlazycat-auth-integrationwhoamihappyhacking/lazycat-skills用于处理懒猫微服(Lazycat MicroServer)应用接入官方认证体系(OIDC单点登录)、HTTP Header用户身份识别、API Auth Token 以及配置独立鉴权(public_path)的专业指南。231skills.sh installs
6davila7 avatarena-databasedavila7/claude-code-templatesAccess European Nucleotide Archive via API/FTP. Retrieve DNA/RNA sequences, raw reads (FASTQ), genome assemblies by accession, for genomics and bioinformatics p218skills.sh installs