Skip to main content
Prisma Documentation Docs

Search documentation

Type to search this documentation.

On this pageOverview

Elysia (/docs/guides/frameworks/elysia)

For the complete Prisma documentation index, see llms.txt. A markdown version of any docs page is available by appending .md to its URL.

Build an Elysia API on Prisma ORM with the elysia template and deploy it to Prisma Compute.

Location: Guides > Frameworks > Elysia

In this guide, you scaffold an Elysia API backed by Prisma ORM, initialize and seed a PostgreSQL database, serve data over HTTP, and deploy the API to Prisma Compute as a Bun app. The elysia template generates the server, so most of the work is understanding the pieces.

Every command and response below was run end to end against a live Prisma Postgres database.

  • Bun 1.1 or later (Elysia is Bun-first)
  • A PostgreSQL connection string, or nothing at all: the scaffold can create a Prisma Postgres database for you

To delegate this guide to your coding agent, copy the prompt below and hand it over:

text
Verify `bun --version` first; if Bun is missing, stop and ask. Create a new Elysia API with Prisma ORM, seed it, and deploy it to Prisma Compute.

1. Scaffold: `bun create prisma@latest my-elysia-api --template elysia --provider postgres --yes`. Then run `bunx prisma@latest init` in `my-elysia-api` so the Prisma agent skills are installed and stay current, and use them. Get a database connection string: use the one I give you, or create a Prisma Postgres database with `npx create-db@latest` and show me the claim URL it prints. Export it as `DATABASE_URL` in the shell; the generated scripts read the environment variable, not `.env`.
2. In `my-elysia-api`, run `bun run db:init` with `DATABASE_URL` exported. Sample users are seeded automatically on the app's first query; there is no separate seed script.
3. Start `bun run dev` in the background, wait until it reports ready, verify `curl http://localhost:3000/users` returns the seeded users, then stop the dev server.
4. Deploy: check `bunx prisma@latest auth whoami`; if I am not signed in, stop and ask me to run `bunx prisma@latest auth login`. Then run `bun run build` followed by `bunx prisma@latest deploy module.ts` and verify the live URL's /users endpoint. The deployed app provisions and seeds its own Prisma Postgres database; do not pass the local DATABASE_URL. If the deploy fails with `HostedStateBootstrapError`, a project with the module's name exists in my workspace but its hosted state cannot be verified; re-run the deploy with `--name <a unique name>`.

Use the installed Prisma ORM skills.
Bash
bun create prisma@latest my-elysia-api --template elysia --provider postgres --no-deploy

Answer the prompts for contract authoring style, package manager, and agent skills. The template generates an Elysia server in src/index.ts with GET / and GET /users routes, the Prisma ORM setup in src/prisma/, and package scripts for the database steps.

Next, set the database connection for the local steps. Use your own PostgreSQL connection string, or create a Prisma Postgres database with npx create-db@latest; it prints a connection string and a claim URL you can open to keep the database. Export the variable in the shell you work in; the generated scripts read the environment variable, not .env:

Bash
export DATABASE_URL="<your connection string>"
Bash
cd my-elysia-api
Bash
bun run db:init
no-copy
"summary": "Applied 5 operation(s) across 1 space(s), database signed"

If db:init stops with Connection terminated unexpectedly, a database you just created is still starting; wait a few seconds and run it again. The command is safe to repeat and reports Applied 0 operation(s) when there is nothing left to do.

Bash
bun run dev

The server starts on port 3000 (set PORT to change it):

Bash
curl http://localhost:3000/users
no-copy
[
  { "id": "1", "email": "alice@prisma.io", "username": "alice", "name": "Alice", "createdAt": "2026-07-24T11:43:41.450Z" },
  { "id": "2", "email": "bob@prisma.io", "username": "bob", "name": "Bob", "createdAt": "2026-07-24T11:43:41.490Z" },
  { "id": "3", "email": "carol@prisma.io", "username": "carol", "name": "Carol", "createdAt": "2026-07-24T11:43:41.533Z" }
]

The route handler is ordinary Elysia code calling an ordinary Prisma ORM query; there is no framework adapter in between. To add write routes, follow the same pattern as the Hono guide's POST route; the query code is identical.

Elysia is supported on Prisma Compute. The scaffold declares the app for Prisma Composer in module.ts and service.ts, pointing at the bundled server the build script produces, so no framework flags are needed. Sign in once (it opens a browser):

Bash
bunx prisma@latest auth login

Then build and deploy from the project directory:

Bash
bun run build
bunx prisma@latest deploy module.ts
no-copy
my-elysia-api
├─ database   postgres-database db_abc123
└─ app        compute-service cps_abc123
              https://xyz.ewr.prisma.build

The deploy creates a project named after your module in your workspace, and re-running the deploy reuses it: the CLI finds the hosted state it stored on the first run and converges the project to your module. If a project with that name exists but the CLI cannot identify or verify its stored state (one left behind by a different checkout, for example), the deploy stops with HostedStateBootstrapError; deploy under another name with --name <unique-name>, or rename the module in module.ts. The deploy also provisions its own Prisma Postgres database on the platform, declared in module.ts; the DATABASE_URL from your local steps is not involved, and the deployed database seeds on the app's first query. Verify the live endpoint returns the seeded users:

Bash
curl https://xyz.ewr.prisma.build/users

For previews per Git branch and deploy on push, see Deploy on push.

[!WARNING] In a long-running server, don't call db.close() in route handlers; the client's connection pool is shared across requests. Close it only on process shutdown.

Run bunx prisma@latest init once to install the Prisma ORM skills for your coding agent and keep them matching your installed packages. Prompts that map to this guide:

  • "Using the prisma-8 skill, add GET /users/:id that returns one user or a 404."
  • "Add a POST /users route that creates a user from the request body."
  • Astro: Set up Prisma ORM in an Astro app with create-prisma, from scaffold to rendered data, and deploy it to Prisma Compute.
  • Hono: Build a Hono API on Prisma ORM with the hono template, add your own routes, and deploy it to Prisma Compute.
  • NestJS: Set up Prisma ORM in a NestJS app with create-prisma, from scaffold to seeded API to a live deploy on Prisma Compute.
  • Next.js: Set up Prisma ORM in a Next.js app with create-prisma, from scaffold to rendered data, and deploy it to Prisma Compute.
  • Nuxt: Set up Prisma ORM in a Nuxt app with create-prisma, from scaffold to rendered data, and deploy it to Prisma Compute.
Suggest an edit

Propose a replacement for this page. The site team reviews it before applying any changes.

Export
Documentation menu