Files
bun-src/docs/guides/http/simple.mdx
T

21 lines
500 B
Plaintext
Raw Normal View History

2026-08-27 21:09:14 +00:00
---
title: Write a simple HTTP server
sidebarTitle: Simple HTTP Server with Bun
mode: center
---
This code starts an HTTP server listening on port `3000`. It responds to every request with a `200` status and the body `"Welcome to Bun!"`.
See [`Bun.serve`](/runtime/http/server) for details.
```ts server.ts icon="/icons/typescript.svg"
const server = Bun.serve({
port: 3000,
fetch(request) {
return new Response("Welcome to Bun!");
},
});
console.log(`Listening on ${server.url}`);
```