Untitled Page

ID: 2299https://elysiajs.com/integrations/vercel.md
Source

Deploy Elysia on Vercel

Elysia can deploys on Vercel with zero configuration using either Bun or Node runtime.

  1. In src/index.ts, create or import an existing Elysia server
  2. Export the Elysia server as default export
import { Elysia, t } from 'elysia'

export default new Elysia() // [!code ++]
    .get('/', () => 'Hello Vercel Function')
    .post('/', ({ body }) => body, {
        body: t.Object({
            name: t.String()
        })
    })
  1. Develop locally with Vercel CLI
vc dev
  1. Deploy to Vercel
vc deploy

That's it. Your Elysia app is now running on Vercel.

Using Node.js

To deploy with Node.js, make sure to set type: module in your package.json

::: code-group

{
  "name": "elysia-app",
  "type": "module" // [!code ++]
}

:::

Using Bun

To deploy with Bun, make sure to set the runtime to Bun in your vercel.json

::: code-group

{
  "$schema": "https://openapi.vercel.sh/vercel.json",
  "bunVersion": "1.x" // [!code ++]
}

If this doesn't work

Vercel has zero configuration for Elysia, for additional configuration, please refers to Vercel documentation