Skip to content
Docs

Elysia on Vercel

Elysia is an ergonomic web framework for building backend servers with Bun. Designed with simplicity and type-safety in mind, Elysia offers a familiar API with extensive support for TypeScript and is optimized for Bun.

You can deploy an Elysia app to Vercel with zero configuration.

Elysia applications on Vercel benefit from:

  • Fluid compute: Active CPU billing, automatic cold start prevention, optimized concurrency, background processing, and more
  • Preview deployments: Test your changes on a copy of your production infrastructure
  • Instant Rollback: Recover from unintended changes or bugs in milliseconds
  • Vercel Firewall: Protect your applications from a wide range of threats with a multi-layered security system
  • Secure Compute: Create private links between your Vercel-hosted backend and other clouds

Get started by initializing a new Elysia project using Vercel CLI init command:

terminal
vc init elysia
Minimum CLI version required: 49.0.0

This will clone the Elysia example repository in a directory called elysia.

To deploy, connect your Git repository or use Vercel CLI:

terminal
vc deploy
Minimum CLI version required: 49.0.0

To run an Elysia application on Vercel, create a file that imports the elysia package at any one of the following locations:

  • app.{js,cjs,mjs,ts,cts,mts}
  • index.{js,cjs,mjs,ts,cts,mts}
  • server.{js,cjs,mjs,ts,cts,mts}
  • src/app.{js,cjs,mjs,ts,cts,mts}
  • src/index.{js,cjs,mjs,ts,cts,mts}
  • src/server.{js,mjs,cjs,ts,cts,mts}

The file must also export the application as a default export of the module. Port listeners (app.listen) are not currently supported.

For example, use the following code that exports your Elysia app:

src/index.js
// For Node.js, ensure "type": "module" in package.json
// (Not required for Bun)
import { Elysia } from 'elysia';
 
const app = new Elysia().get('/', () => ({
  message: 'Hello from Elysia on Vercel!',
}));
 
// Export the Elysia app
export default app;
src/index.ts
// For Node.js, ensure "type": "module" in package.json
// (Not required for Bun)
import { Elysia } from 'elysia';
 
const app = new Elysia().get('/', () => ({
  message: 'Hello from Elysia on Vercel!',
}));
 
// Export the Elysia app
export default app;

Running your application using app.listen is currently not supported. For now, prefer export default app.

To deploy your Elysia app without an account or login, run this command in the project root:

terminal
vercel deploy --temporary

The CLI builds the project, deploys it to production, and prints a claim URL. Claim the project to keep it live. See Deploying without logging in.

To run your Elysia application locally, you can use Vercel CLI:

terminal
vc dev
Minimum CLI version required: 49.0.0

Use Vercel Services to deploy an Elysia backend and a frontend in one project. Configure service routing to expose the backend at a public path, or use service bindings for private calls from the frontend's server code.

Ensure type is set to module in your package.json file:

package.json
{
  "name": "elysia-app",
  "type": "module"
}
Minimum CLI version required: 49.0.0

To use the Bun runtime on Vercel, configure the runtime in vercel.json:

vercel.json
{
  "$schema": "https://openapi.vercel.sh/vercel.json",
  "bunVersion": "1.4.x"
}

For more information, visit the Bun runtime on Vercel documentation.

In Elysia, you can use plugins and lifecycle hooks to run code before and after request handling. This is commonly used for logging, auth, or request processing:

src/index.ts
import { Elysia } from 'elysia';
 
const app = new Elysia()
  .onBeforeHandle(({ request }) => {
    // Runs before route handler
    console.log('Request:', request.url);
  })
  .onAfterHandle(({ response }) => {
    // Runs after route handler
    console.log('Response:', response.status);
  })
  .get('/', () => 'Hello Elysia!');
 
export default app;

In Vercel, Routing Middleware executes before a request is processed by your application. Use it for rewrites, redirects, headers, or personalization, and combine it with Elysia's own lifecycle hooks as needed.

When you deploy an Elysia app to Vercel, your server endpoints automatically run as Vercel Functions and use Fluid compute by default.

Use a generator handler with yield to stream response chunks from Elysia. See the Elysia streaming example for plain text and server-sent events.

Use Cron Jobs to call an Elysia route on a schedule. Configure the route and schedule, then check the request's Authorization header against your CRON_SECRET environment variable before running the task. See the Elysia cron job example.

Use Runtime Logs to inspect application output and errors, and Observability to investigate request duration and failures. See monitoring Elysia with Observability for details.

Last updated November 14, 2026

Was this helpful?

supported.