Skip to content

Cloudflare R2

bash
npm install @aws-sdk/client-s3 @aws-sdk/s3-request-presigner
ts
disks: {
  r2: {
    driver: 'r2',
    config: {
      bucket: 'my-bucket',
      endpoint: 'https://<account-id>.r2.cloudflarestorage.com',
      credentials: { accessKeyId: '...', secretAccessKey: '...' },
    },
  },
},

R2 is S3-API compatible, so this driver is a thin wrapper around the s3 driver with sensible defaults baked in:

  • region defaults to 'auto' if you don't set one
  • visibility is always forced to 'private'
  • supportsACL is always forced to false

...regardless of what you pass for those three — R2 doesn't support S3-style ACLs, so there's nothing to configure there.

Everything else — getSignedUrl, getSignedUploadUrl, CloudFront-style CDN signing via cdn/cdnUrl — behaves exactly like the S3 driver, since R2Driver extends it.

Released under the MIT License.