Skip to content

Prisma.Compute reference

Source: src/Prisma/App.ts

A Prisma App, the long-lived application configuration that owns deployments.

Omit branchId and branchGitName to attach the App to the project’s current default branch. App regions are immutable; create a second App and cut traffic over when moving regions. Use Prisma.Compute for the usual build, deployment, health-check, and promotion workflow; use App directly when managing standalone Prisma.Deployment resources.

App on the default branch

const app = yield* Prisma.App("web", {
project,
});

App on a preview branch

const app = yield* Prisma.App("preview-web", {
project,
branchId: preview.branchId,
});

Source: src/Prisma/Compute.ts

Build and deploy an application to Prisma Compute.

Prisma’s create-deployment API exposes neither an idempotency key nor a caller-defined recovery key. If the API commits a deployment but its create response is lost before Alchemy persists the returned ID, that deployment can remain orphaned and a later deploy may create another one. Alchemy does not guess that the App’s latest deployment is owned, because it could belong to another actor. Use a durable, locked state backend and inspect the App’s deployment history after an interrupted create.

Deploy a directory with an entrypoint

const app = yield* Prisma.Compute("api", {
project: project.projectId,
path: "./apps/api",
entrypoint: "server.ts",
port: 3000,
});

Deploy an Effect-native HTTP app

export default Prisma.Compute(
"api",
{
project,
appName: "api",
main: import.meta.filename,
port: 8080,
},
Effect.gen(function* () {
return {
fetch: Effect.succeed(HttpServerResponse.text("ok")),
};
}),
);

main is bundled with rolldown at deploy time. Unused code is tree-shaken. effect, alchemy, and @distilled.cloud are marked pure so unused parts prune more aggressively. Your app is not marked pure.

Mark additional packages as pure

Only list packages with no top-level side effects.

{
main: "./src/app.ts",
bundle: {
extra: { pure: { packages: ["my-lib", "@my-scope/*"] } },
},
}

Turn it off

{
main: "./src/app.ts",
bundle: { extra: { pure: false } },
}

Bind a Prisma Connection

export default Prisma.Compute(
"api",
{
project,
appName: "api",
main: import.meta.filename,
},
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)),
);

Build before upload and replace old versions

const app = yield* Prisma.Compute("api", {
project: project.projectId,
path: "./apps/api",
build: {
command: "bun build src/server.ts --target bun --outdir dist",
outdir: "dist",
entrypoint: "server.js",
},
port: 8080,
env: {
// Use this for a standalone Connection. A project's default database
// is injected by Prisma without an explicit DATABASE_URL entry.
DATABASE_URL: connection.databaseUrl,
},
destroyOldDeployment: true,
});

Auto-build a framework app

const app = yield* Prisma.Compute("api", {
project: project.projectId,
path: "./apps/web",
build: "auto",
destroyOldDeployment: true,
});

Deploy a static site

const web = yield* Prisma.Compute("web", {
project,
path: "./site",
build: {
type: "static",
outdir: ".",
},
});

Deploy a prebuilt tar.gz artifact

const app = yield* Prisma.Compute("api", {
project: project.projectId,
artifactPath: "./dist/app.tar.gz",
port: 8080,
});
const app = yield* Prisma.Compute("api", {
project,
path: "./apps/api",
entrypoint: "server.ts",
healthCheck: {
path: "/api/health",
// Defaults to any 2xx response when omitted.
statusCodes: [200, 204],
},
});
const app = yield* Prisma.Compute("api", {
project: project.projectId,
path: "./apps/api",
entrypoint: "server.ts",
dev: {
command: "bun run dev",
port: 3000,
},
});

Source: src/Prisma/CustomDomain.ts

A Prisma app custom domain.

Domains can only attach to Apps on the project’s current default branch. Creating this resource starts asynchronous DNS and certificate provisioning; configure the returned dnsRecords and inspect status, foundryStatus, and failureReason before routing production traffic.

App and hostname changes are intentionally rejected because the Management API cannot replace a live domain atomically. Create a second resource, verify DNS and TLS, cut traffic over, and then remove the old resource.

const domain = yield* Prisma.CustomDomain("api-domain", {
app: api.appId,
hostname: "api.example.com",
});

Source: src/Prisma/Deployment.ts

A Prisma deployment owned by an App.

This is the low-level resource: it can upload or reuse an artifact, start it, and promote it, but it does not provide Prisma.Compute’s preview/stable health checks or automatic rollback. Prefer Prisma.Compute for production application deployments.

Prisma’s create-deployment API currently exposes neither an idempotency key nor a caller-defined natural key. After a crash that loses state immediately after creation, Alchemy deliberately does not adopt the App’s latest deployment: doing so could take ownership of an unrelated deployment. When persisted state contains a Foundry version ID, refresh may safely recover the matching deployment.

Fork the currently promoted artifact

const deployment = yield* Prisma.Deployment("web-v2", {
app: app.appId,
skipCodeUpload: true,
start: true,
promote: true,
});

Upload a prebuilt artifact

const deployment = yield* Prisma.Deployment("web-v3", {
app: app.appId,
artifactPath: "./dist/app.tar.gz",
artifactContentType: "application/gzip",
start: true,
promote: true,
});

Source: src/Prisma/EnvironmentVariable.ts

A Prisma compute environment variable.

Values are write-only in Prisma. Alchemy stores them as Redacted values and reapplies the desired value to repair drift.

Project-level production variable

yield* Prisma.EnvironmentVariable("api-url", {
project: project.projectId,
// No branchId: this is a project-level template.
class: "production",
key: "API_URL",
value: Redacted.make("https://api.example.com"),
});

Preview branch override

yield* Prisma.EnvironmentVariable("preview-api-url", {
project,
branchId: preview.branchId,
// Branch overrides always use the preview class.
class: "preview",
key: "API_URL",
value: Redacted.make("https://preview.example.com"),
});

Source: src/Prisma/SourceRepository.ts

A linked source repository for Prisma apps.

GitHub is currently the only supported provider. Linking requires an existing Prisma SCM installation. providerRepositoryId is GitHub’s permanent numeric repository ID; retrieve it with gh api repos/OWNER/REPO --jq '.id'. When installationId is omitted, Prisma selects the workspace installation.

Linking creates or renames the repository-owned default branch. Observe that branch through the Management API; do not declare it again as a separate Prisma.Branch resource. Use this resource’s outputs to order downstream databases and apps after the link side effects complete. Deleting the link does not roll those side effects back: existing branches, databases, and apps remain in the project.

The project, repository ID, provider, and installation form an immutable link identity. Alchemy refuses an automatic relink because unlinking cannot roll back branch and resource attachments. Existing links require explicit adoption.

SourceRepository: Finding the Repository ID

Section titled “SourceRepository: Finding the Repository ID”
Terminal window
gh api repos/OWNER/REPO --jq '.id'
const repo = yield* Prisma.SourceRepository("repo", {
project: project.projectId,
// Replace with the value returned by the GitHub command above.
providerRepositoryId: 123456789,
});
const database = yield* Prisma.Database("database", {
project: repo.projectId,
branchGitName: repo.defaultBranch,
});