Blogga qaytish

ElysiaJS — The Bun-Powered Backend Framework That's Changing the Game

Discover ElysiaJS, an ergonomic web framework built for Bun runtime that combines Express-like simplicity with exceptional performance and end-to-end type safety.

Elyor Djalalov Elyor Djalalov
5 min read
ElysiaJS — The Bun-Powered Backend Framework That's Changing the Game

If you’re building APIs in JavaScript/TypeScript and haven’t looked at ElysiaJS yet, you’re missing out on something special.

What is ElysiaJS?

Elysia is an ergonomic web framework built specifically for the Bun runtime. It combines Express-like simplicity with exceptional performance and end-to-end type safety. The tagline says it all: “Ergonomic Framework for Humans”.

Why It Caught My Attention

Blazing Fast Performance

ElysiaJS Benchmark Results

The numbers speak for themselves:

  • 21x faster than Express
  • 6x faster than Fastify
  • 2,454,631 requests/second in TechEmpower benchmarks

To put this in perspective, Elysia running on Bun rivals performance numbers typically seen only in Go and Rust frameworks. For a JavaScript/TypeScript framework, this is remarkable.

Framework Performance Comparison (requests/second):
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Elysia (Bun)    ████████████████████████  2,454,631
Gin (Go)        ████████                    676,019
Spring (Java)   ██████                      506,087
Fastify (Node)  █████                       415,600
Express (Node)  █                           113,117
Nest (Node)     █                           105,064

End-to-End Type Safety

Like tRPC, but without the complexity. Types flow seamlessly from backend to frontend with zero code generation.

import { Elysia, t } from 'elysia'

const app = new Elysia()
  .post('/user', ({ body }) => {
    // body is fully typed as { name: string, email: string }
    return {
      id: crypto.randomUUID(),
      ...body,
      createdAt: new Date()
    }
  }, {
    body: t.Object({
      name: t.String(),
      email: t.String({ format: 'email' })
    })
  })

The schema defines validation AND types in one place. No duplication, no drift between runtime validation and TypeScript types.

OpenAPI Documentation in One Line

Just add .use(openapi()) and you have full API documentation. No annotations needed, no separate spec files to maintain:

import { Elysia } from 'elysia'
import { openapi } from '@elysiajs/openapi'

const app = new Elysia()
  .use(openapi())  // That's it! Visit /swagger
  .get('/health', () => 'OK')
  .listen(3000)

Bring Your Own Validator

Works with your favorite validation library:

  • Zod — The most popular choice
  • Valibot — Lightweight alternative
  • ArkType — Fast and type-safe
  • Effect — For functional programming enthusiasts

Any Standard Schema compliant library works seamlessly while maintaining full type inference and OpenAPI compatibility.

Eden Treaty: Type-Safe Client

One of Elysia’s killer features is Eden Treaty — a type-safe client that syncs with your server automatically:

// server.ts
import { Elysia, t } from 'elysia'

export const app = new Elysia()
  .get('/posts', () => posts)
  .post('/posts', ({ body }) => createPost(body), {
    body: t.Object({
      title: t.String(),
      content: t.String()
    })
  })

export type App = typeof app
// client.ts
import { treaty } from '@elysiajs/eden'
import type { App } from './server'

const api = treaty<App>('localhost:3000')

// Fully typed! IDE autocomplete works perfectly
const { data, error } = await api.posts.post({
  title: 'Hello World',
  content: 'My first post'
})

No code generation. No build step. Just import the type and go.

Real-World Example: REST API

Here’s a more complete example showing Elysia’s ergonomic design:

import { Elysia, t } from 'elysia'
import { openapi } from '@elysiajs/openapi'
import { cors } from '@elysiajs/cors'

const app = new Elysia()
  .use(openapi())
  .use(cors())

  // Group related routes
  .group('/api/users', app => app
    .get('/', async () => {
      const users = await db.user.findMany()
      return users
    })

    .get('/:id', async ({ params: { id } }) => {
      const user = await db.user.findUnique({ where: { id } })
      if (!user) throw new Error('User not found')
      return user
    }, {
      params: t.Object({
        id: t.String()
      })
    })

    .post('/', async ({ body }) => {
      return db.user.create({ data: body })
    }, {
      body: t.Object({
        name: t.String({ minLength: 2 }),
        email: t.String({ format: 'email' })
      })
    })
  )

  .listen(3000)

console.log(`🦊 Elysia running at http://localhost:3000`)

Built-in Features That Matter

  • File uploads with native validation
  • WebSocket support via µWebSocket (the fastest WS library)
  • Stream responses using generator functions
  • Static file serving out of the box

Runtime Flexibility

While Elysia is optimized for Bun, it’s built on Web Standards and runs on:

  • Bun (recommended for best performance)
  • Node.js
  • Deno
  • Vercel Edge Functions

No vendor lock-in, despite Bun’s performance advantages.

Getting Started

# Create a new project
bun create elysia app

# Or add to existing project
bun add elysia

Should You Use It?

Yes, if you:

  • Want maximum performance from TypeScript
  • Value end-to-end type safety
  • Are already using or considering Bun
  • Build APIs and want automatic OpenAPI docs
  • Prefer ergonomic, minimal boilerplate code

Maybe wait if you:

  • Need a battle-tested ecosystem (Elysia is newer)
  • Are heavily invested in Express middleware
  • Require enterprise support

Conclusion

ElysiaJS represents a new wave of backend frameworks that refuse to compromise. You get the developer experience of Express, the type safety of tRPC, the performance of Go, and the documentation of OpenAPI — all in one package.

The project is community-driven, well-documented, and actively maintained. If you’re exploring modern backend alternatives or experimenting with Bun, Elysia deserves a serious look.

Links:


What’s your experience with Bun-based frameworks? Have you tried Elysia in production? Let’s connect!

Elyor Djalalov

Elyor Djalalov

Katta dastur muhandisi. Veb-dasturlash, dasturiy ta'minot arxitekturasi va muhandislik haqida yozaman.

Barcha maqolalar →