Files
bun.sh/docs/guides/http/simple.md
2025-07-10 00:10:43 -07:00

19 lines
420 B
Markdown

---
name: Write a simple HTTP server
---
This starts an HTTP server listening on port `3000`. It responds to all requests with a `Response` with status `200` and body `"Welcome to Bun!"`.
See [`Bun.serve`](https://bun.com/docs/api/http) for details.
```ts
const server = Bun.serve({
port: 3000,
fetch(request) {
return new Response("Welcome to Bun!");
},
});
console.log(`Listening on ${server.url}`);
```