Elysia runs on Bun and can be shipped as a self-contained binary, a bundled JavaScript file, or a Docker image. Compiling before deployment typically reduces memory usage by 2–3× compared to running source files directly.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.
Cluster mode
Elysia is single-threaded by default. To use all available CPU cores, fork multiple workers with Node’scluster module.
Compile to binary
Compiling to a self-contained binary produces a portable executable that does not require Bun to be installed on the target machine.| Flag | Purpose |
|---|---|
--compile | Compile TypeScript to a native binary |
--minify-whitespace | Remove unnecessary whitespace |
--minify-syntax | Reduce JavaScript syntax to decrease file size |
--target bun | Optimize the output for Bun’s runtime |
--outfile server | Name the output binary server |
Cross-platform targets
Add--target with a platform identifier to cross-compile for a different OS or architecture:
| Target | OS | Architecture | libc |
|---|---|---|---|
bun-linux-x64 | Linux | x64 | glibc |
bun-linux-arm64 | Linux | arm64 | glibc |
bun-linux-x64-musl | Linux | x64 | musl |
bun-linux-arm64-musl | Linux | arm64 | musl |
bun-windows-x64 | Windows | x64 | — |
bun-darwin-x64 | macOS | x64 | — |
bun-darwin-arm64 | macOS | arm64 | — |
Why not --minify?
--minify renames functions to single characters. If you use OpenTelemetry, this breaks tracing because OpenTelemetry relies on function names. Use --minify-whitespace and --minify-syntax instead.
If you are not using OpenTelemetry, --minify is safe:
Linux permissions
Some distributions require execute permission to be set before the binary can run:Compile to JavaScript
If you cannot produce a binary (e.g., deploying to a Windows server), bundle to a single JavaScript file instead:Docker
Use a multi-stage Dockerfile: build the binary in the Bun image, then copy it into a minimal Distroless base image.OpenTelemetry with Docker
OpenTelemetry instruments libraries via monkey-patchingnode_modules. To keep instrumented packages available at runtime, exclude them from bundling with --external:
dependencies (not devDependencies) in package.json:
Monorepo with Docker
When using Turborepo or a similar monorepo manager, place the Dockerfile inside the app directory and build from the repo root:Railway
Railway assigns a random port to each deployment via thePORT environment variable. Update your server to read it: