Skip to content

Prisma

Prisma’s data platform gives you serverless Postgres and a managed app runtime. With alchemy you declare the project, its databases, the connections your apps use, and the Compute deployments that run them — all as resources in one Stack. In dev mode the same Stack runs against a local @prisma/dev Postgres with nothing to provision.

New here? Set up credentials first.

A Prisma.Project is the top-level container. A Prisma.Postgres database lives inside it, and a Prisma.Connection materializes the credentials an application uses to reach that database:

const project = yield* Prisma.Project("app", {
createDatabase: false,
});
const postgres = yield* Prisma.Postgres("db", {
project,
});
const connection = yield* Prisma.Connection("api", {
database: postgres,
});

Names are optional everywhere — omit them and alchemy generates stable physical names from the Stack, logical ID, and stage.

The connection exposes ready-to-use outputs — a conventional databaseUrl, direct and pooled connection strings, and parsed origin components for poolers like Hyperdrive. See Connections.

Branches group databases under git-style names — a preview branch per stage, promoted to default when it ships.

Prisma.Compute builds, uploads, and promotes an application next to its database — either a framework app built from a directory, or an Effect-native app defined inline:

const app = yield* Prisma.Compute("api", {
project,
path: "./app",
build: {
command: "bun run build",
outdir: ".output",
entrypoint: "server/index.mjs",
},
port: 3000,
healthCheck: { path: "/api/health" },
env: {
DATABASE_URL: connection.databaseUrl,
},
});

Deployments are verified against the health check before promotion and rolled back when it fails — see Compute.

Inside a Compute app, Lambda function, or Cloudflare Worker, Prisma.Connect turns a Connection into a typed runtime client whose databaseUrl feeds straight into SQL.Postgres or Drizzle:

Effect.gen(function* () {
const db = yield* Prisma.Connect(connection);
const sql = yield* SQL.Postgres({ url: db.databaseUrl });
return {
fetch: Effect.gen(function* () {
const users = yield* sql`SELECT * FROM users`;
return yield* HttpServerResponse.json(users);
}),
};
}).pipe(Effect.provide(Prisma.ConnectBinding));

On Cloudflare, Prisma Postgres slots into the same path as the other Postgres providers:

  1. Hyperdrive pools the connection’s direct origin at the edge
  2. Drizzle or SQL.Postgres gives the Worker a typed query layer over that connection
  3. Connect from Workers walks through both wiring styles