# Elysia (/docs/guides/v8/frameworks/elysia)

> For the complete Prisma documentation index, see [llms.txt](https://www.prisma.io/docs/llms.txt). A markdown version of any docs page is available by appending `.md` to its URL.

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

Location: Guides > v8 (RC) > Frameworks > Elysia

## Introduction [#introduction]

In this guide, you scaffold an Elysia API backed by Prisma 8, initialize and seed a PostgreSQL database, serve data over HTTP, and deploy the API to [Prisma Compute](https://www.prisma.io/docs/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.

## Prerequisites [#prerequisites]

* [Bun](https://bun.sh/) 1.1 or later (Elysia is Bun-first)
* A PostgreSQL connection string, or nothing at all: the scaffold can create a [Prisma Postgres](https://www.prisma.io/docs/postgres) database for you

## Use with your agent [#use-with-your-agent]

Prefer to delegate this guide? Copy the prompt and hand it to your coding agent:

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

1. Scaffold: `bunx create-prisma@next create my-elysia-api --template elysia --provider postgres --yes`. Then 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 and write it to `my-elysia-api/.env` for the deploy step; 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 `npx @prisma/cli@latest auth whoami`; if I am not signed in, stop and ask me to run `npx @prisma/cli@latest auth login`. Then run `npx @prisma/cli@latest app deploy --create-project my-elysia-api --env .env --framework bun --entry src/index.ts` and verify the live URL's /users endpoint.

Use the installed Prisma 8 skills.
```

## 1. Scaffold the project [#1-scaffold-the-project]

```bash
bunx create-prisma@next create my-elysia-api --template elysia --provider postgres
```

Pick your database at the prompt. The template generates an Elysia server in `src/index.ts` with `GET /` and `GET /users` routes, the Prisma 8 setup in `src/prisma/`, and package scripts for the database steps.

Next, set the database connection. 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, and write it to `.env` for the deploy step later. The generated scripts read the environment variable, not `.env`:

```bash
export DATABASE_URL="<your connection string>"
echo "DATABASE_URL=\"$DATABASE_URL\"" > .env
```

```bash
cd my-elysia-api
```

## 2. Initialize the database [#2-initialize-the-database]

```bash
bun run db:init
```

```text no-copy
"summary": "Applied 5 operation(s) across 1 space(s), database signed"
```

## 3. Run the server [#3-run-the-server]

```bash
bun run dev
```

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

```bash
curl http://localhost:3000/users
```

```json 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 8 query; there is no framework adapter in between. To add write routes, follow the same pattern as the [Hono guide's POST route](https://www.prisma.io/docs/guides/v8/frameworks/hono#4-add-a-post-route); the query code is identical.

## 4. Deploy to Prisma Compute [#4-deploy-to-prisma-compute]

Elysia apps run on [Prisma Compute](https://www.prisma.io/docs/compute) as Bun apps, so the API can go from your terminal to a live URL in one command. Sign in once (it opens a browser):

  

#### bun

```bash
bunx @prisma/cli@latest auth login
```

#### pnpm

```bash
pnpm dlx @prisma/cli@latest auth login
```

#### yarn

```bash
yarn dlx @prisma/cli@latest auth login
```

#### npm

```bash
npx @prisma/cli@latest auth login
```

Then deploy from the project directory. Compute does not auto-detect Elysia yet, so pass `--framework bun` with the server entry file. The `--env .env` flag passes your `DATABASE_URL` to the deployment, so the live API talks to the same database:

  

#### bun

```bash
bunx @prisma/cli@latest app deploy --env .env --framework bun --entry src/index.ts
```

#### pnpm

```bash
pnpm dlx @prisma/cli@latest app deploy --env .env --framework bun --entry src/index.ts
```

#### yarn

```bash
yarn dlx @prisma/cli@latest app deploy --env .env --framework bun --entry src/index.ts
```

#### npm

```bash
npx @prisma/cli@latest app deploy --env .env --framework bun --entry src/index.ts
```

```text no-copy
First deploy of "my-elysia-api" -- promoting to production.
Building locally...
  Built      1.2 MB
Uploading...
Deploying...
Live in 8.8s
https://<your-app>.ewr.prisma.build
```

Verify the live endpoint returns the seeded users:

```bash
curl https://<your-app>.ewr.prisma.build/users
```

The first deploy asks you to pick or create a project (pass `--create-project my-elysia-api` to skip the prompt), pins the directory to it in a gitignored `.prisma/local.json`, and promotes to production. For previews per Git branch and deploy-on-push, see [Deploy your first app](https://www.prisma.io/docs/prisma-compute/deploy).

## Common gotchas [#common-gotchas]

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

## Prompt your coding agent [#prompt-your-coding-agent]

The scaffold installs [Prisma 8 skills](https://www.prisma.io/docs/ai/tools/skills#available-skills-for-prisma-8) for your coding agent. 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."

## Next steps [#next-steps]

* [Learn the fundamentals](https://www.prisma.io/docs/orm/v8/fundamentals/reading-data): filtering, sorting, pagination, and writes.
* [Read the Prisma 8 overview](https://www.prisma.io/docs/orm/v8) for the concepts behind contracts and typed queries.
* [Use the Hono guide](https://www.prisma.io/docs/guides/v8/frameworks/hono) for the tested POST route pattern.

## Related pages

- [`Astro`](https://www.prisma.io/docs/guides/v8/frameworks/astro): Set up Prisma 8 in an Astro app with create-prisma, from scaffold to rendered data, and deploy it to Prisma Compute.
- [`Hono`](https://www.prisma.io/docs/guides/v8/frameworks/hono): Build a Hono API on Prisma 8 with the hono template, add your own routes, and deploy it to Prisma Compute.
- [`NestJS`](https://www.prisma.io/docs/guides/v8/frameworks/nestjs): Set up Prisma 8 in a NestJS app with create-prisma, from scaffold to seeded API to a live deploy on Prisma Compute.
- [`Next.js`](https://www.prisma.io/docs/guides/v8/frameworks/nextjs): Set up Prisma 8 in a Next.js app with create-prisma, from scaffold to rendered data, and deploy it to Prisma Compute.
- [`Nuxt`](https://www.prisma.io/docs/guides/v8/frameworks/nuxt): Set up Prisma 8 in a Nuxt app with create-prisma, from scaffold to rendered data, and deploy it to Prisma Compute.