Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/anomalyco/sst/llms.txt

Use this file to discover all available pages before exploring further.

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]
});