Elysia — Ergonomic TypeScript Web Framework for Bun
Elysia is a fast, ergonomic TypeScript web framework optimized for Bun runtime. End-to-end type safety, OpenAPI support, and performance that rivals Go and Rust frameworks.
Staging sûr pour cet actif
Cet actif est d'abord staged. Le prompt copié demande à l'agent d'inspecter les fichiers staged avant d'activer scripts, config MCP ou config globale.
npx -y tokrepo@latest install bb30e2f1-3559-11f1-9bc6-00163e2b0d79 --target codexStage les fichiers d'abord; l'activation exige la revue du README et du plan staged.
What it is
Elysia is a TypeScript web framework optimized for the Bun runtime. It provides end-to-end type safety from route definition to client consumption, automatic OpenAPI documentation generation, and performance benchmarks that rival Go and Rust frameworks. The framework emphasizes ergonomic API design with minimal boilerplate.
This tool is for TypeScript developers who want fast API development with strong typing. It is especially attractive to teams already using or evaluating Bun as a Node.js alternative.
How it saves time or tokens
Elysia's type inference eliminates the need for separate type definitions, validation schemas, and API documentation. You define a route with its schema once, and Elysia infers types throughout the chain. The framework generates OpenAPI specs automatically, saving the work of maintaining API docs manually.
How to use
- Install Bun and create a new Elysia project.
- Define routes with typed schemas.
- Run the server.
- Access the auto-generated Swagger UI.
# Install Bun
curl -fsSL https://bun.sh/install | bash
# Create project
mkdir my-api && cd my-api
bun init
bun add elysia @elysiajs/swagger
# Run the server
bun run src/index.ts
Example
import { Elysia, t } from 'elysia'
import { swagger } from '@elysiajs/swagger'
const app = new Elysia()
.use(swagger())
.get('/users/:id', ({ params: { id } }) => {
return { id, name: 'Alice', email: 'alice@example.com' }
}, {
params: t.Object({
id: t.String()
}),
response: t.Object({
id: t.String(),
name: t.String(),
email: t.String()
})
})
.post('/users', ({ body }) => {
return { id: crypto.randomUUID(), ...body }
}, {
body: t.Object({
name: t.String(),
email: t.String({ format: 'email' })
})
})
.listen(3000)
console.log('Server running on port 3000')
Types flow from schema to handler to response automatically.
Related on TokRepo
- AI coding tools — More development tools
- Automation tools — API and workflow automation
Common pitfalls
- Elysia requires Bun. It does not run on Node.js or Deno. If your deployment target only supports Node, Elysia is not an option.
- The ecosystem is smaller than Express or Fastify. Some middleware or integrations may not exist yet.
- Bun itself is still maturing. Some Node.js APIs are not fully supported in Bun, which can affect third-party library compatibility.
- End-to-end type safety only works when using Elysia's schema system. Bypassing it with manual types loses the benefit.
- Production deployment patterns for Bun differ from Node.js. PM2 and some hosting platforms may need adjustments.
Questions fréquentes
Elysia on Bun is significantly faster than Express on Node.js in benchmarks. The exact multiplier depends on the workload, but typical benchmarks show 5-10x higher throughput for JSON serialization and routing.
Yes. Elysia has built-in WebSocket support with the same type-safe schema system used for HTTP routes. Define message schemas and get full type inference on WebSocket handlers.
Yes. Elysia works with Prisma, Drizzle, and other TypeScript-compatible ORMs. Use Elysia plugins to integrate database connections and share them across route handlers.
Yes. The @elysiajs/swagger plugin automatically generates OpenAPI 3.0 documentation from your route schemas. Access the Swagger UI at /swagger by default.
Elysia is used in production by many teams, though Bun itself is newer than Node.js. Evaluate Bun compatibility with your specific dependencies before deploying to production.
Sources citées (3)
- Elysia GitHub— Elysia is a TypeScript web framework for Bun
- Elysia Documentation— Elysia documentation and API reference
- Bun Documentation— Bun runtime performance and compatibility
En lien sur TokRepo
Fil de discussion
Actifs similaires
Axum — Ergonomic Modular Web Framework for Rust
Axum is a web application framework built on Tokio, Tower, and Hyper. Focuses on ergonomics and modularity with a macro-free routing API, seamless Tower middleware integration, and type-safe extractors. The official Tokio team web framework.
Vuetify — Material Design Component Framework for Vue
Vuetify is the most popular Material Design component framework for Vue 3. 80+ beautifully crafted components following Material Design 3 guidelines with SSR support, theming, treeshaking, and accessibility baked in.
Hexo — Fast Node.js Blog Framework with Plugin Ecosystem
Hexo is a fast, simple, and extensible blog framework powered by Node.js. It renders Markdown posts into static HTML in seconds and supports hundreds of themes and plugins.
Makepad — Creative Software Development Platform for Rust
Makepad is a Rust-based UI framework and live-coding IDE that compiles to WebGL, Metal, DirectX, and OpenGL. It combines a visual design environment with a high-performance rendering engine for building desktop, mobile, and web applications.