
Bun Http Server
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-codeInstalls 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- Bun Test Mocking335
- Nuxt Seo335
- Bun Bundler334
- Bun Workers333
- Bun Shell331
- Bun React Ssr330
- Bun Tanstack Start329
- Cloudflare Workers Performance329
- Bun Hot Reloading328
- Bun Redis328
- Bun Ffi326
- Bun Jest Migration326
- Bun Websocket Server326
- Cloudflare Workers Runtime Apis326
- Swift Best Practices326
- Bun Nuxt323
- Bun Macros322
- Cloudflare Workers Frameworks321
- Supabase Postgres Best Practices319
- Cloudflare Workers Ci Cd318
- Cloudflare Workers Dev Experience317
- Cloudflare Workers Observability315
- Cloudflare Workers Migration310
- Cloudflare Workers Multi Lang310