> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/zhcndoc/bun/llms.txt
> Use this file to discover all available pages before exploring further.

# Build an HTTP server with Express

> Use Express.js with Bun

Express works with Bun with full Node.js compatibility.

## Installation

```bash theme={null}
bun add express
bun add -d @types/express
```

## Basic Server

```typescript server.ts theme={null}
import express from "express";

const app = express();
const port = 3000;

app.get("/", (req, res) => {
  res.send("Hello from Express + Bun!");
});

app.listen(port, () => {
  console.log(`Server running at http://localhost:${port}`);
});
```

Run with:

```bash theme={null}
bun run server.ts
```

## Middleware

```typescript theme={null}
import express from "express";

const app = express();

app.use(express.json());

app.post("/api/data", (req, res) => {
  res.json({ received: req.body });
});

app.listen(3000);
```

<Tip>
  For better performance, consider using `Bun.serve()` or lightweight frameworks like Hono or Elysia.
</Tip>
