Skip to main content
The Bucket component lets you add a Cloudflare R2 bucket to your app.

Constructor

sst.config.ts
const bucket = new sst.cloudflare.Bucket("MyBucket");

Parameters

public

public
boolean
default:"false"
Enable public access to the bucket.
{
  public: true
}

Properties

name

domain

nodes

SDK

Access the bucket in your worker:
src/worker.ts
import { Resource } from "sst";

export default {
  async fetch(request, env) {
    const object = await env.MyBucket.get("file.txt");
    return new Response(await object.text());
  }
};

Examples

Create a bucket

sst.config.ts
const bucket = new sst.cloudflare.Bucket("MyBucket");
sst.config.ts
const bucket = new sst.cloudflare.Bucket("MyBucket");

new sst.cloudflare.Worker("MyWorker", {
  handler: "src/worker.ts",
  link: [bucket]
});

Build docs developers (and LLMs) love