Elysia supports Cloudflare Workers through an experimental Cloudflare Worker adapter. The adapter enables Ahead of Time (AoT) compilation, taking advantage of Cloudflare’s support for function compilation during startup introduced in compatibility dateDocumentation 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.
2025-06-01.
Initialize a new Worker project with Wrangler
You need Wrangler to scaffold and run your Worker locally.
Add the CloudflareAdapter to your app
Import
CloudflareAdapter from elysia/adapter/cloudflare-worker, pass it as the adapter option, and call .compile() before exporting.Calling
.compile() is required for Elysia to work on Cloudflare Workers.Set compatibility_date in your Wrangler config
AoT compilation requires
compatibility_date set to at least 2025-06-01.Bindings
Access Cloudflare Workers bindings by importingenv from cloudflare:workers:
Static files
The Static Plugin does not work on Cloudflare Workers due to the absence of thefs module. Use Cloudflare’s built-in static asset serving instead.
Add the assets field to your Wrangler config:
public folder. Given the following structure:
/kyuukurarin.mp4 and /static/mika.webp.
Limitations
| Limitation | Details |
|---|---|
Elysia.file and Static Plugin | Not supported — no fs module available |
| OpenAPI Type Gen | Not supported — no fs module available |
| Inline response values | Cannot define Response before server start |