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, 147 flashcards. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.
A jump-to index of every table row in this cheat sheet.
An interactive map of every table and concept in this topic.
Table 1: Installation & Quick Start
Getting from nothing to a running server is famously short with Elysia—install Bun, scaffold a project, and you have a typed HTTP server listening on a port in a handful of lines. These entries cover that first stretch: installing the runtime, chaining your first routes, configuring the listener, and reading back the underlying Bun server so you know exactly what you've started.
| 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 | ||
new Elysia() .get('/:id', ({params: {id}}) => id) | Automatically infers types from route patterns without manual type declarations. id is typed as string. | ||
.listen({ port: 3000, hostname: '0.0.0.0'}) | • Configure server port and hostname • Supports callback for server start confirmation | ||
.listen(process.env.PORT ?? 3000) | Use environment variable for port (required for platforms like Railway). Falls back to 3000 in development. | ||
const app = new Elysia().listen(3000)console.log(app.server) | • Access underlying Bun server instance • Provides hostname, port, and other server details | ||
const app = new Elysia().listen(3000)app.stop() | • Properly close server connections • Returns void when shutdown completes |