The best way to control Claude Code, Codex and more from any computer or phone

main
mdx 138 lines 4.63 KB
Raw
1 ---
2 title: Prisma
3 description: Prisma Postgres and Prisma Compute — projects, databases, connections, and deployed apps as Stack resources, with a zero-config local database in dev.
4 ---
5
6 Prisma's data platform gives you serverless Postgres and a managed
7 app runtime. With alchemy you declare the project, its databases,
8 the connections your apps use, and the Compute deployments that run
9 them — all as resources in one Stack. In dev mode the same Stack
10 runs against a local `@prisma/dev` Postgres with nothing to
11 provision.
12
13 New here? [Set up credentials](/prisma/setup), then follow the
14 [four-part tutorial](/prisma/tutorial/part-1) to deploy a Project, an
15 Effect-native API, Postgres, and a Vite frontend.
16
17 ## Resources
18
19 A `Prisma.Project` is the top-level container. By default it creates
20 a Prisma Postgres database in `us-east-1`:
21
22 ```typescript
23 const project = yield* Prisma.Project("app", {
24 region: "us-east-1",
25 });
26 ```
27
28 Prisma injects that database's system-managed `DATABASE_URL` and
29 `DATABASE_URL_POOLED` variables into Compute deployments
30 automatically.
31
32 When you need a database with an independent lifecycle and explicit
33 connection outputs, declare it separately:
34
35 ```typescript
36 const project = yield* Prisma.Project("app", { createDatabase: false });
37
38 const postgres = yield* Prisma.Postgres("db", {
39 project,
40 });
41
42 const connection = yield* Prisma.Connection("api", {
43 database: postgres,
44 });
45 ```
46
47 Display names are optional for these resources — omit them and alchemy
48 generates stable physical names from the Stack, logical ID, and stage.
49
50 The connection exposes ready-to-use outputs — a conventional
51 `databaseUrl`, direct and pooled connection strings, and parsed
52 `origin` components for poolers like Hyperdrive. See
53 [Connections](/prisma/data/connections).
54
55 [Branches](/prisma/data/branches) group databases and apps under
56 git-style names. A standalone `Prisma.Branch` has Prisma's `preview`
57 role even when promoted to be the project's default branch.
58
59 ## Websites
60
61 Use [`Prisma.Website`](/prisma/frontend/websites) for Vite, Astro
62 (SSR or static), Next.js, Nuxt, SvelteKit, React Router, SolidStart,
63 TanStack Start, Waku, Octane, Foldkit, Vocs, or any static build.
64 The framework's Node-target output runs on Bun in Prisma Compute,
65 uploaded as `tar.gz` — no Docker image or registry. Even static sites
66 run a Compute static-file server.
67
68 Omit `project` for a database-less project created only on live deploy.
69 `alchemy dev` runs the native framework dev server without creating
70 Prisma resources for the Website. Start with the
71 [Vite guide](/prisma/frontend/vite) or [framework overview](/prisma/frontend/websites).
72
73 ## Compute
74
75 `Prisma.Compute` builds, uploads, and promotes an application next
76 to its database — either a framework app built from a directory, or
77 an Effect-native app defined inline:
78
79 ```typescript
80 const app = yield* Prisma.Compute("api", {
81 project,
82 path: "./app",
83 build: "auto",
84 healthCheck: { path: "/api/health" },
85 });
86 ```
87
88 For a standalone database, pass `connection.databaseUrl` explicitly
89 as shown in [Connections](/prisma/data/connections).
90
91 The candidate health check gates promotion. If the stable endpoint
92 fails after promotion, alchemy attempts to restore the previous
93 deployment and fails closed if recovery cannot converge. See
94 [Deployments](/prisma/compute/deployments).
95
96 ## Runtime bindings
97
98 Inside a Compute app, Lambda function, or Cloudflare Worker,
99 `Prisma.Connect` turns a Connection into a typed runtime client
100 whose `databaseUrl` feeds straight into
101 [Prisma ORM v8](/sql/prisma/postgres), `SQL.Postgres`, or Drizzle:
102
103 ```typescript
104 Effect.gen(function* () {
105 const db = yield* Prisma.Connect(connection);
106 const sql = yield* SQL.Postgres({ url: db.databaseUrl });
107
108 return {
109 fetch: Effect.gen(function* () {
110 const users = yield* sql`SELECT * FROM users`;
111 return yield* HttpServerResponse.json(users);
112 }),
113 };
114 }).pipe(Effect.provide(Prisma.ConnectBinding));
115 ```
116
117 ## The Prisma path
118
119 On Cloudflare, Prisma Postgres slots into the same path as the other
120 Postgres providers:
121
122 1. [Hyperdrive](/cloudflare/data/hyperdrive) pools the connection's
123 direct `origin` at the edge
124 2. [Prisma ORM v8](/sql/prisma/postgres),
125 [Drizzle](/cloudflare/data/drizzle), or
126 [`SQL.Postgres`](/sql/effect-sql/postgres) gives the Worker a
127 typed query layer over that connection
128 3. [Connect from Workers](/prisma/guides/cloudflare-workers) walks
129 through both wiring styles
130
131 ## Reference
132
133 - [Project](/providers/prisma/project)
134 - [Database](/providers/prisma/database)
135 - [Connection](/providers/prisma/connection)
136 - [Branch](/providers/prisma/branch)
137 - [Compute](/providers/prisma/compute)
138 - [SourceRepository](/providers/prisma/sourcerepository)