1---
2title: Buckets
3description: Prisma Buckets provision S3-compatible object storage inside a project, and Bucket access keys mint the S3 credentials — access key, one-time secret, endpoint, and the provider-side bucket name.
4---
5
6A `Prisma.Bucket` is an Object Store bucket inside a Prisma
7project. A `Prisma.BucketAccessKey` is an access key for one bucket and
8yields the S3 credentials your app connects with.
9
10```typescript
11import * as Prisma from "alchemy/Prisma";
12
13const bucket = yield* Prisma.Bucket("uploads", {
14 project,
15 name: "uploads",
16});
17
18const key = yield* Prisma.BucketAccessKey("uploads-key", {
19 bucket,
20 role: "read_write",
21});
22```
23
24## Bucket access key outputs
25
26```typescript
27key.accessKeyId; // S3 access key ID
28key.secretAccessKey; // S3 secret, Redacted — returned once at creation
29key.endpoint; // S3-compatible endpoint URL
30key.bucketName; // provider-side S3 bucket name (e.g. user-<id>)
31```
32
33Prisma returns `secretAccessKey` exactly once, in the create
34response. Alchemy persists it `Redacted` in state and never re-reads
35it from the API, so keep your state store somewhere durable.
36
37S3 clients must use `key.bucketName` — the provider-side name — as
38the bucket, not the friendly display name you chose on the bucket:
39
40```typescript
41const app = yield* Prisma.Compute("api", {
42 project,
43 path: "./app",
44 env: {
45 S3_ENDPOINT: key.endpoint,
46 S3_BUCKET: key.bucketName,
47 S3_ACCESS_KEY_ID: key.accessKeyId,
48 S3_SECRET_ACCESS_KEY: key.secretAccessKey,
49 },
50});
51```
52
53## Roles
54
55A key's `role` is `"read"` or `"read_write"` and is fixed at
56creation — changing it (or the key's name or bucket) replaces the
57key and mints fresh credentials.
58
59## Deletion
60
61Destroying a bucket deletes its objects and revokes any remaining
62keys server-side. A `Prisma.BucketAccessKey` destroyed after its bucket
63tolerates the already-revoked key.
64
65## Branch-scoped buckets
66
67Pass `branchId` to scope a bucket to a branch, e.g. for per-preview
68storage:
69
70```typescript
71const previewBucket = yield* Prisma.Bucket("preview-uploads", {
72 project,
73 branchId: preview.branchId,
74});
75```
76
77## The bucket bindings
78
79Inside a Prisma Compute app, AWS Lambda function, or Cloudflare Worker, bind the bucket instead of wiring credentials by hand. `Prisma.ReadBucket`, `Prisma.WriteBucket`, and `Prisma.ReadWriteBucket` each mint a scoped `Prisma.BucketAccessKey` for the bucket, carry its credentials into the host, and resolve to a typed client at runtime:
80
81```typescript
82Effect.gen(function* () {
83 const uploads = yield* Prisma.ReadWriteBucket(bucket);
84
85 return {
86 fetch: Effect.gen(function* () {
87 yield* uploads.put("hits", "1");
88 const object = yield* uploads.get("hits");
89 return yield* HttpServerResponse.text(
90 object === null ? "" : yield* object.text(),
91 );
92 }),
93 };
94}).pipe(Effect.provide(Prisma.ReadWriteBucketBinding));
95```
96
97`ReadBucket` mints a `read`-role key, so its credential genuinely cannot write. The store has no write-only role, so `WriteBucket` carries a `read_write` credential and enforces write-only at the client.
98
99## Where next
100
101- [Compute](/prisma/compute/apps) — the host the bindings deliver to.
102
103Reference:
104
105- [Bucket API reference](/providers/prisma/bucket)
106- [BucketAccessKey API reference](/providers/prisma/bucketaccesskey)
107- [ReadBucket](/providers/prisma/readbucket) / [WriteBucket](/providers/prisma/writebucket) / [ReadWriteBucket](/providers/prisma/readwritebucket)