Skip to content
TypeScript
1.8 KB
Raw Blame
---
title: Setup
description: Connect alchemy to Prisma — account, service tokens, and profiles.
---

import PackageManagers from "../../../components/PackageManagers.astro";

Sign up at [prisma.io](https://www.prisma.io) and create a service
token in the [Prisma Console](https://console.prisma.io) (workspace
settings → service tokens). Install `@alchemy.run/prisma`:

<PackageManagers add="@alchemy.run/prisma" />

Then register the provider next to your cloud's:

```typescript
// alchemy.run.ts
import * as Alchemy from "alchemy";
import * as Cloudflare from "@alchemy.run/cloudflare";
import * as Prisma from "@alchemy.run/prisma";
import * as Effect from "effect/Effect";
import * as Layer from "effect/Layer";

export default Alchemy.Stack(
  "App",
  {
    providers: Layer.mergeAll(
      Cloudflare.providers(),
      Prisma.providers(),
    ),
    state: Alchemy.localState(),
  },
  Effect.gen(function* () {
    // Declare Prisma and Cloudflare resources here.
  }),
);
```

Run `alchemy profile edit --add Prisma`. The service token is entered
interactively and saved under
`~/.alchemy/credentials/<profile>/prisma-stored.json`.

In CI (`CI=true`), profiles are bypassed. Set `PRISMA_SERVICE_TOKEN` or
`PRISMA_API_TOKEN`; Alchemy reads it directly and persists nothing.

See [Profiles](/environments/profiles) for how credentials are stored
and switched.

## Local dev

`bun alchemy dev` needs no Prisma credentials. Database resources run
against a local `@prisma/dev` Postgres, Compute resources run their
configured `dev.command`, and the remaining Prisma resources return
compatible local outputs. See
[Postgres](/prisma/data/postgres) for the dev database options.

## Next steps

- [Tutorial: Your First Project](/prisma/tutorial/part-1) — build a full-stack Prisma application in four parts.
- [Prisma overview](/prisma) — resources and compositions.