Elysia in 100 Seconds

Published: (February 1, 2026 at 06:00 PM EST)
2 min read
Source: Dev.to

Source: Dev.to

Overview

ElysiaJS is a high‑performance, statically typed web framework that runs on the Bun runtime. It is known for being significantly faster than Express and aims to provide a developer‑friendly API while retaining raw speed.

Features

  • Speed – Leverages Bun’s Just‑In‑Time compiler for microsecond‑level startup times.
  • Type safety – Uses TypeBox to provide end‑to‑end type safety without runtime performance penalties or extensive boilerplate.
  • Fluent API – Routes are defined with a chainable syntax (.get(), .post(), etc.) that returns plain objects automatically serialized to JSON.
  • Schema validation – Attach a schema object via the t variable to validate incoming data at runtime and infer TypeScript types for IDE autocompletion.
  • Eden Treaty – Allows the frontend to import backend type definitions directly, giving full autocompletion for API calls on the client side.
  • Minimal decorators – Unlike NestJS, Elysia does not require complex decorator usage to define routes.

Getting Started

  1. Install Bun (if you haven’t already).

  2. Create a TypeScript file (e.g., app.ts).

  3. Initialize the app:

    import { Elysia, t } from "elysia";
    
    const app = new Elysia();
  4. Define a route using the fluent API:

    app.get("/", () => {
      return { message: "Hello, Elysia!" };
    });
  5. Add schema validation (optional but recommended):

    app.get(
      "/user/:id",
      {
        params: t.Object({
          id: t.String(),
        }),
      },
      ({ params }) => {
        // `params.id` is guaranteed to be a string
        return { userId: params.id };
      }
    );
  6. Run the server:

    bun run app.ts

    The server will start up in microseconds, ready to handle requests.

Summary

ElysiaJS combines the speed of Bun with robust type safety and a concise, chainable API, making it a compelling alternative to traditional Node.js frameworks like Express and NestJS. Its built‑in schema validation and Eden Treaty further streamline full‑stack development by keeping backend and frontend type definitions in sync.

0 views
Back to Blog

Related posts

Read more »