| 1 | --- |
| 2 | title: Setup |
| 3 | description: Connect alchemy to Prisma — account, service tokens, and profiles. |
| 4 | --- |
| 5 | |
| 6 | Sign up at [prisma.io](https://www.prisma.io) and create a service |
| 7 | token in the [Prisma Console](https://console.prisma.io) (workspace |
| 8 | settings → service tokens). Register the provider next to your |
| 9 | cloud's: |
| 10 | |
| 11 | ```typescript |
| 12 | // alchemy.run.ts |
| 13 | import * as Alchemy from "alchemy"; |
| 14 | import * as Cloudflare from "alchemy/Cloudflare"; |
| 15 | import * as Prisma from "alchemy/Prisma"; |
| 16 | import * as Effect from "effect/Effect"; |
| 17 | import * as Layer from "effect/Layer"; |
| 18 | |
| 19 | export default Alchemy.Stack( |
| 20 | "App", |
| 21 | { |
| 22 | providers: Layer.mergeAll( |
| 23 | Cloudflare.providers(), |
| 24 | Prisma.providers(), |
| 25 | ), |
| 26 | state: Alchemy.localState(), |
| 27 | }, |
| 28 | Effect.gen(function* () { |
| 29 | // Declare Prisma and Cloudflare resources here. |
| 30 | }), |
| 31 | ); |
| 32 | ``` |
| 33 | |
| 34 | Run `alchemy profile edit --add Prisma`. The service token is entered |
| 35 | interactively and saved under |
| 36 | `~/.alchemy/credentials/<profile>/prisma-stored.json`. |
| 37 | |
| 38 | In CI (`CI=true`), profiles are bypassed. Set `PRISMA_SERVICE_TOKEN` or |
| 39 | `PRISMA_API_TOKEN`; Alchemy reads it directly and persists nothing. |
| 40 | |
| 41 | See [Profiles](/environments/profiles) for how credentials are stored |
| 42 | and switched. |
| 43 | |
| 44 | ## Local dev |
| 45 | |
| 46 | `bun alchemy dev` needs no Prisma credentials. Database resources run |
| 47 | against a local `@prisma/dev` Postgres, Compute resources run their |
| 48 | configured `dev.command`, and the remaining Prisma resources return |
| 49 | compatible local outputs. See |
| 50 | [Postgres](/prisma/data/postgres) for the dev database options. |
| 51 | |
| 52 | ## Next steps |
| 53 | |
| 54 | - [Tutorial: Your First Project](/prisma/tutorial/part-1) — build a full-stack Prisma application in four parts. |
| 55 | - [Prisma overview](/prisma) — resources and compositions. |