Documentation Index Fetch the complete documentation index at: https://mintlify.com/elysiajs/documentation/llms.txt
Use this file to discover all available pages before exploring further.
Elysia is a TypeScript backend framework with support for multiple runtimes, optimized for Bun. The steps below walk you through getting a running server regardless of which runtime you are targeting.
Install Bun Elysia is optimized for Bun, a fast JavaScript runtime designed as a drop-in replacement for Node.js. curl -fsSL https://bun.sh/install | bash
Auto installation
Manual installation
Create a project The fastest way to start is with bun create elysia, which scaffolds a project with sensible defaults:
Scaffold the project
This creates an app folder with Elysia installed and a starter src/index.ts.
Enter the project directory
Start the development server
Navigate to http://localhost:3000 . You should see Hello Elysia. The dev command uses Bun’s --watch flag to reload the server automatically on file changes.
Manual setup If you prefer to set up a project from scratch, install Elysia and Bun type definitions:
Install dependencies
bun add elysia
bun add -d @types/bun
Create the entry point
Create src/index.ts with the following content: import { Elysia } from 'elysia'
const app = new Elysia ()
. get ( '/' , () => 'Hello Elysia' )
. listen ( 3000 )
console . log (
`Elysia is running at ${ app . server ?. hostname } : ${ app . server ?. port } `
)
Add scripts to package.json
{
"scripts" : {
"dev" : "bun --watch src/index.ts" ,
"build" : "bun build src/index.ts --target bun --outdir ./dist" ,
"start" : "NODE_ENV=production bun dist/index.js" ,
"test" : "bun test"
}
}
dev — runs with hot reload during development
build — compiles for production
start — runs the compiled output
Configure TypeScript
Create tsconfig.json or add the following to an existing one. Strict mode is required for Elysia’s type inference to work correctly: {
"compilerOptions" : {
"strict" : true
}
}
Install Node.js macOS (Homebrew)
Windows (Chocolatey)
apt (Debian / Ubuntu)
pacman (Arch Linux)
We recommend using TypeScript. Select the tab that matches your preference:
Install dependencies
Elysia on Node.js requires the @elysia/node adapter. Install Elysia, the adapter, and TypeScript tooling: bun add elysia @elysia/node && \
bun add -d tsx @types/node typescript
tsx is a TypeScript runner with hot reload and modern dev tooling built in.
Create the entry point
Create src/index.ts: import { Elysia } from 'elysia'
import { node } from '@elysia/node'
const app = new Elysia ({ adapter: node () })
. get ( '/' , () => 'Hello Elysia' )
. listen ( 3000 , ({ hostname , port }) => {
console . log ( `Elysia is running at ${ hostname } : ${ port } ` )
})
Add scripts to package.json
{
"scripts" : {
"dev" : "tsx watch src/index.ts" ,
"build" : "tsc src/index.ts --outDir dist" ,
"start" : "NODE_ENV=production node dist/index.js"
}
}
Initialize TypeScript
Then update tsconfig.json to enable strict mode: {
"compilerOptions" : {
"strict" : true
}
}
Using Elysia without TypeScript means you will miss out on automatic type inference, autocomplete, end-to-end type safety with Eden, and advanced compile-time checks — all of which are core features of the framework.
Install dependencies
bun add elysia @elysia/node
Create the entry point
Create src/index.js: import { Elysia } from 'elysia'
import { node } from '@elysia/node'
const app = new Elysia ({ adapter: node () })
. get ( '/' , () => 'Hello Elysia' )
. listen ( 3000 , ({ hostname , port }) => {
console . log ( `Elysia is running at ${ hostname } : ${ port } ` )
})
Add scripts to package.json
{
"type" : "module" ,
"scripts" : {
"dev" : "node src/index.js" ,
"start" : "NODE_ENV=production node src/index.js"
}
}
WinterTC / Web Standard runtimes Elysia is WinterTC compliant , meaning it runs on any framework or runtime that supports the Web Standard Request / Response API.
Choose a runtime
Select a platform that supports Web Standard Request/Response:
Cloudflare Workers Deploy Elysia as a Cloudflare Worker.
Next.js Use Elysia inside Next.js API routes.
Expo Elysia as Expo App Router API routes.
Astro Elysia as Astro API routes.
SvelteKit Elysia as SvelteKit API routes.
Vercel Elysia as Vercel Edge Functions.
Custom runtime fallback
If your runtime is not listed, expose app.fetch as the request handler: import { Elysia } from 'elysia'
const app = new Elysia ()
. get ( '/' , () => 'Hello Elysia' )
export default app . fetch
Any runtime that accepts a (request: Request) => Response | Promise<Response> function is compatible.
Next steps
Now that your server is running, explore the core concepts:
Routing Define routes, path parameters, query strings, and method handlers.
Validation Validate requests at runtime using Elysia.t, Zod, Valibot, and more.
Eden client Connect a frontend with end-to-end type safety and no code generation.
Plugins Add CORS, JWT, OpenAPI, static files, and more with official plugins.