Elysia is an ergonomic, high-performance TypeScript web framework built for Bun that delivers exceptional speed (255k+ requests/second), end-to-end type safety with automatic inference, and seamless integration with the Bun runtime. The framework combines a developer-friendly API with powerful features like automatic OpenAPI generation, lifecycle hooks, plugin architecture, and Eden Treaty for type-safe client-server communication—all while requiring minimal TypeScript boilerplate.
What This Cheat Sheet Covers
This topic spans 15 focused tables and 208 indexed concepts. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.
Table 1: Installation & Quick StartTable 2: Basic Routing & Path ParametersTable 3: Handler Context & UtilitiesTable 4: Request Validation (Schema Builder)Table 5: Lifecycle Hooks & EventsTable 6: Plugin System & Dependency InjectionTable 7: Cookie & Session ManagementTable 8: WebSocket ImplementationTable 9: Eden Treaty (End-to-End Type Safety)Table 10: Error Handling & ValidationTable 11: OpenAPI & DocumentationTable 12: Official Plugins (Common Use Cases)Table 13: Testing PatternsTable 14: Performance OptimizationTable 15: Deployment & Production
Table 1: Installation & Quick Start
| Feature | Example | Description |
|---|---|---|
curl -fsSL | bash | • JavaScriptruntime optimized for performance • required to run Elysia at full speed • Alternative: use with Node.js using polyfills | |
bun create elysia app | • Scaffolds new Elysia project with automatic setup • Navigate to directory with cd app after creation | |
import { Elysia } from 'elysia'new Elysia().get('/', 'Hello').listen(3000) | Minimal Elysia server listening on port 3000. Returns "Hello" for GET / requests. | |
bun dev | • Starts development server with hot-reload on file changes • Automatically restarts on code modifications | |
new Elysia() .get('/', 'Hello') .post('/user', ({body}) => body) .listen(3000) | • Chain multiple route handlers • Supports GET, POST, PUT, PATCH, DELETE, and custom HTTP methods |