Overview
bunway brings Express-compatible routing to Bun without sacrificing Bun's native speed. The goal is simple: if you know Express, you know bunway.
Express Compatibility
bunway uses the exact same (req, res, next) handler signature as Express. Your existing middleware patterns work here.
Who is bunway for?
- Express developers wanting Bun's speed without learning a new API
- Teams migrating Node.js apps to Bun
- Anyone who prefers the battle-tested Express patterns over newer abstractions
Goals
- Express-compatible – same
(req, res, next)signature, familiar middleware patterns - Bun-native – built on Bun's Fetch primitives (
Request,Response,Bun.serve) - Batteries included – 19 middleware covering most production needs
- Zero dependencies – pure Bun, no Node polyfills
Current capabilities
bunway ships with everything you need for production apps:
Core
bunway()factory withapp.listen()- Express-compatible
(req, res, next)handler signature BunRequestandBunResponsehelpers- Sub-routers with middleware inheritance
- Router finalizer that merges middleware headers
- Graceful shutdown via
app.close() - Native HTTPS/TLS support
X-Forwarded-Protosupport behind reverse proxies
Built-in Middleware
| Middleware | Description | Express Equivalent |
|---|---|---|
json() | JSON body parsing | express.json() |
urlencoded() | URL-encoded body parsing | express.urlencoded() |
text() | Text body parsing | body-parser.text() |
cors() | CORS handling | cors |
helmet() | Security headers | helmet |
session() | Session management | express-session |
cookieParser() | Cookie parsing | cookie-parser |
compression() | Response compression | compression |
serveStatic() | Static file serving | express.static() |
rateLimit() | Rate limiting | express-rate-limit |
csrf() | CSRF protection | csurf |
passport() | Authentication | passport |
logger() | Request logging | morgan |
upload() | File uploads (multipart) | multer |
timeout() | Request timeout | connect-timeout |
hpp() | HPP protection | hpp |
validate() | Request validation | express-validator |
errorHandler() | Error handling | Custom middleware |
Quick example
ts
import bunway, { cors, json, helmet, session, logger } from "bunway";
const app = bunway();
// Familiar middleware stack
app.use(logger("dev"));
app.use(cors({ origin: true }));
app.use(helmet());
app.use(json());
app.use(session({ secret: "keyboard cat" }));
// Express-style routes
app.get("/", (req, res) => res.json({ message: "Hello bunway!" }));
app.get("/users/:id", (req, res) => {
res.json({ id: req.params.id });
});
app.listen({ port: 3000 });Request & Response
- Content Negotiation — RFC 7231 quality-value parsing for Accept headers
- Regex Routes — use RegExp as route patterns with named capture groups
- Catch-all Routes —
app.all("*", handler)for 404 handlers - Cache Validation —
req.fresh/req.stalefor 304 responses - Range Requests —
req.range()+ automaticres.sendFile()partial content (206) - JSONP —
res.jsonp()for legacy cross-domain support - Cross-References —
req.res,res.req,res.appfor Express parity - Array Paths —
app.use(['/v1', '/v2'], router)for multi-path mounting - Sub-App Mounting —
app.mountpathproperty andapp.path()method for mounted sub-apps
What's next?
Core features, request/response completeness, and security middleware are done. Active development focuses on:
- Developer experience — SSE helpers, response time, request ID
- Performance — continued optimization and benchmarking
See Roadmap & Contributions for the full picture.
Philosophy
- Express patterns, Bun speed: Familiar APIs, native performance
- Community-led: We build what developers actually need
- Transparent: Full TypeScript support with documented types
Ready to build? Continue with Getting Started or jump to the Express Migration Guide.