Introduction to bun-router
What is bun-router?
bun-router is a high-performance, feature-rich router designed specifically for Bun applications. Built from the ground up to take advantage of Bun's speed and features, it provides an intuitive and powerful API for handling HTTP routing in your web applications.
Key Features
- Fast and Efficient: Optimized for performance with Bun's native features
- Complete HTTP Method Support: Handle GET, POST, PUT, DELETE, PATCH, OPTIONS, and HEAD requests
- Advanced Routing: Path parameters, constraints, groups, and nested routes
- Middleware Support: Built-in middleware and easy custom middleware creation
- WebSocket Integration: Seamless WebSocket support with pub/sub capabilities
- Type Safety: First-class TypeScript support with type inference
- Developer Experience: Intuitive API that makes development a joy
Why Choose bun-router?
Performance
bun-router is built to leverage Bun's speed and efficiency. It integrates directly with Bun's Bun.serve()
API to provide optimal routing performance without unnecessary overhead.
Feature Completeness
Whether you're building a simple API or a complex web application, bun-router
has the features you need - from basic routing to advanced patterns like domain routing, resource routing, and WebSocket communication.
Type Safety
With first-class TypeScript support, bun-router
provides type safety throughout your application. Route parameters are automatically inferred, and middleware is fully typed.
Easy to Learn, Hard to Outgrow
bun-router is designed to be easy to get started with, but powerful enough to handle complex routing needs as your application grows.
Next Steps
Ready to get started? Check out the Installation Guide to add bun-router
to your project.