bun-http-server
SolidUse when building HTTP servers with Bun.serve, handling requests/responses, implementing routing, creating REST APIs, or configuring fetch handlers.
API & Backend 251 stars
36 forks Updated yesterday MIT
Install
Quality Score: 92/100
Stars 20%
Recency 20%
Frontmatter 20%
Documentation 15%
Issue Health 10%
License 10%
Description 5%
Skill Content
# Bun HTTP Server
Bun has a built-in high-performance HTTP server via `Bun.serve()`.
## Quick Start
```typescript
const server = Bun.serve({
port: 3000,
fetch(req) {
return new Response("Hello World!");
},
});
console.log(`Server running at http://localhost:${server.port}`);
```
## Request Handling
```typescript
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
```typescript
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
```typescript
Bun.serve({
fetch(req) {
const url = new URL(req.url);
switch (url.pathname) {
case "/json":
return Response.json({ message: "Hello" });
case "/html":
return new Response("<h1>Hello</h1>", {
headers: { "Content-Type": "text/html" },
});
case "/redirect":
return Response.redirect("/new-location", 302);
cas...
Details
- Author
- secondsky
- Repository
- secondsky/claude-skills
- Created
- 1 years ago
- Last Updated
- yesterday
- Language
- TypeScript
- License
- MIT
Integrates with
Similar Skills
Semantically similar based on skill content — not just same category
Web & Frontend Listed
bun-websockets
Server-side WebSockets in Bun
67 Updated 8 months ago
diegosouzapw Web & Frontend Listed
bun-websockets
Server-side WebSockets in Bun
9 Updated 9 months ago
jarle AI & Automation Listed
bun-patterns
When to activate: Bun runtime, Bun.serve, Bun.file, bun test, bun build, bun shell, SQLite, performance-first Node.js alternative
2 Updated 2 months ago
Mattakushi432