| 1 | --- |
| 2 | title: Apps |
| 3 | description: Prisma Compute apps as Stack resources — framework builds or Effect-native services, env wiring, custom domains, and a local dev command. |
| 4 | --- |
| 5 | |
| 6 | `Prisma.Compute` deploys an application onto Prisma's managed |
| 7 | runtime. One resource covers the whole path: optional build, artifact |
| 8 | upload, deployment, health check, and promotion — see |
| 9 | [Deployments](/prisma/compute/deployments) for the lifecycle. |
| 10 | |
| 11 | ## Framework apps |
| 12 | |
| 13 | For frontend frameworks, prefer the [`Prisma.Website` family](/prisma/frontend/websites). |
| 14 | It provides framework-specific builds and native dev servers with the |
| 15 | same `rootDir`, `env`, `assets`, `dev`, and `domain` vocabulary as other |
| 16 | providers. Its output still runs on Bun in Compute, including static |
| 17 | sites. Use `Prisma.Compute` directly for custom builds, server apps, |
| 18 | and the Effect-native handlers below. |
| 19 | |
| 20 | Point `path` at the app. With `build: "auto"`, alchemy detects the |
| 21 | framework, builds it, archives the output, and deploys the correct |
| 22 | server entrypoint: |
| 23 | |
| 24 | ```typescript |
| 25 | const app = yield* Prisma.Compute("api", { |
| 26 | project, |
| 27 | path: "./app", |
| 28 | build: "auto", |
| 29 | healthCheck: { path: "/api/health" }, |
| 30 | destroyOldDeployment: true, |
| 31 | }); |
| 32 | ``` |
| 33 | |
| 34 | The server must listen on `PORT` (injected at runtime). Auto-build |
| 35 | supports Bun, Next.js, Nuxt, Astro, TanStack Start, Vite, and NestJS. Generic |
| 36 | Vite projects are deployed as static SPAs. Use an |
| 37 | explicit build object when an app needs a custom command, output |
| 38 | directory, or entrypoint. |
| 39 | |
| 40 | When `Prisma.Project` creates its default database, Prisma injects |
| 41 | system-managed `DATABASE_URL` and `DATABASE_URL_POOLED` values into |
| 42 | Compute deployments. Leave those keys out of `env`. For a standalone |
| 43 | `Prisma.Postgres` database, create a `Prisma.Connection` and pass its |
| 44 | outputs explicitly as shown in [Connections](/prisma/data/connections). |
| 45 | |
| 46 | `app.url` is the deployed endpoint. |
| 47 | |
| 48 | ## Static sites |
| 49 | |
| 50 | Generic Vite apps work with `build: "auto"`. To deploy a directory that already |
| 51 | contains static files, set `build.type` to `"static"` and point `outdir` at it. |
| 52 | Alchemy packages the files with the HTTP entrypoint Prisma Compute requires; |
| 53 | the application does not need its own server file or runtime dependency: |
| 54 | |
| 55 | ```typescript |
| 56 | const site = yield* Prisma.Compute("web", { |
| 57 | project, |
| 58 | path: "./site", |
| 59 | build: { |
| 60 | type: "static", |
| 61 | outdir: ".", |
| 62 | }, |
| 63 | }); |
| 64 | ``` |
| 65 | |
| 66 | Add `command` when the output directory needs to be built first: |
| 67 | |
| 68 | ```typescript |
| 69 | const site = yield* Prisma.Compute("web", { |
| 70 | project, |
| 71 | path: "./app", |
| 72 | build: { |
| 73 | type: "static", |
| 74 | command: "bun run build", |
| 75 | outdir: "dist", |
| 76 | spa: true, |
| 77 | }, |
| 78 | dev: { command: "bun run dev", port: 5173 }, |
| 79 | }); |
| 80 | ``` |
| 81 | |
| 82 | Set `spa: true` for client-side routers so unmatched paths serve |
| 83 | `index.html`. Leave it disabled for static sites that should return `404` for |
| 84 | missing files. Directory indexes redirect to a trailing-slash URL so relative |
| 85 | asset links resolve correctly. |
| 86 | |
| 87 | For static builds, `archiveIgnore` patterns are relative to `outdir`. The |
| 88 | configured index page must remain in the archive; excluding it rejects the |
| 89 | deployment. |
| 90 | |
| 91 | ## Effect-native apps |
| 92 | |
| 93 | Pass `main` and an Effect body instead of a build, and the app is |
| 94 | bundled from your Stack file — same shape as an Effect-native |
| 95 | Cloudflare Worker or Lambda: |
| 96 | |
| 97 | ```typescript |
| 98 | export default Prisma.Compute( |
| 99 | "api", |
| 100 | { project, main: import.meta.filename }, |
| 101 | Effect.gen(function* () { |
| 102 | const db = yield* Prisma.Connect(connection); |
| 103 | const sql = yield* SQL.Postgres({ url: db.databaseUrl }); |
| 104 | |
| 105 | return { |
| 106 | fetch: Effect.gen(function* () { |
| 107 | const users = yield* sql`SELECT * FROM users`; |
| 108 | return yield* HttpServerResponse.json(users); |
| 109 | }), |
| 110 | }; |
| 111 | }).pipe(Effect.provide(Prisma.ConnectBinding)), |
| 112 | ); |
| 113 | ``` |
| 114 | |
| 115 | ## Custom domains |
| 116 | |
| 117 | Custom domains can only attach to an app on the project's current |
| 118 | default branch. Creating the resource starts DNS and certificate |
| 119 | provisioning; use `domain.dnsRecords` to configure DNS and inspect |
| 120 | `domain.status` before directing production traffic: |
| 121 | |
| 122 | ```typescript |
| 123 | const domain = yield* Prisma.CustomDomain("api-domain", { |
| 124 | app, |
| 125 | hostname: "api.example.com", |
| 126 | }); |
| 127 | ``` |
| 128 | |
| 129 | Changing the hostname or app in place is intentionally rejected. |
| 130 | Create a second domain, verify DNS and TLS, cut traffic over, and then |
| 131 | remove the old resource. |
| 132 | |
| 133 | ## Local dev |
| 134 | |
| 135 | Under `bun alchemy dev`, `dev.command` runs your app locally (e.g. |
| 136 | `vite dev`) with the same env the deployed app would see — including |
| 137 | connection bindings, which resolve to the local |
| 138 | [dev database](/prisma/data/postgres#local-dev): |
| 139 | |
| 140 | ```typescript |
| 141 | const app = yield* Prisma.Compute("web", { |
| 142 | project, |
| 143 | path: ".", |
| 144 | dev: { command: "bun run dev" }, |
| 145 | env: { DATABASE_URL: connection.databaseUrl }, |
| 146 | }); |
| 147 | ``` |
| 148 | |
| 149 | ## Where next |
| 150 | |
| 151 | - [Deployments](/prisma/compute/deployments) — health-checked |
| 152 | promotion, rollback, and deployment reuse. |
| 153 | - [Connections](/prisma/data/connections) — the env and binding |
| 154 | wiring in detail. |
| 155 | |
| 156 | Reference: |
| 157 | |
| 158 | - [Compute API reference](/providers/prisma/compute) |
| 159 | - [CustomDomain API reference](/providers/prisma/customdomain) |