R2 (4)

Last updated Oct 1, 2026 Manage your R2 configurations using Wrangler.

r2 bucket

Interact with buckets in an R2 store.

Note

The r2 bucket commands allow you to manage application data in the Cloudflare network to be accessed from Workers using the R2 API.

r2 bucket create

Create a new R2 bucket

npmyarnpnpm

npx wrangler r2 bucket create <NAME>
yarn wrangler r2 bucket create <NAME>
pnpm wrangler r2 bucket create <NAME>
  • <NAME> string required

The name of the new bucket - --location string The optional location hint that determines geographic placement of the R2 bucket - --storage-class string alias: --s

The default storage class for objects uploaded to this bucket - --jurisdiction string alias: --J

The jurisdiction where the new bucket will be created - --use-remote boolean Use a remote binding when adding the newly created resource to your config - --update-config boolean Automatically update your config file with the newly added resource - --binding string The binding name of this resource in your Worker

<details>

<summary>

Global flags

</summary>

  • <code>--v</code><code>boolean</code> alias: --version

Show version number - <code>--cwd</code><code>string</code>Run as if Wrangler was started in the specified directory instead of the current working directory - <code>--config</code><code>string</code> alias: --c

Path to Wrangler configuration file - <code>--env</code><code>string</code> alias: --e

Environment to use for operations, and for selecting .env and .dev.vars files - <code>--env-file</code><code>string</code>Path to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files - <code>--install-skills</code><code>boolean</code> default: false

Install Cloudflare skills for detected AI coding agents before running the command - <code>--profile</code><code>string</code>Use a specific auth profile

</details>

r2 bucket info

Get information about an R2 bucket

npmyarnpnpm

npx wrangler r2 bucket info <BUCKET>
yarn wrangler r2 bucket info <BUCKET>
pnpm wrangler r2 bucket info <BUCKET>
  • <BUCKET> string required

The name of the bucket to retrieve info for - --jurisdiction string alias: --J

The jurisdiction where the bucket exists - --json boolean default: false

Return the bucket information as JSON

<details>

<summary>

Global flags

</summary>

  • <code>--v</code><code>boolean</code> alias: --version

Show version number - <code>--cwd</code><code>string</code>Run as if Wrangler was started in the specified directory instead of the current working directory - <code>--config</code><code>string</code> alias: --c

Path to Wrangler configuration file - <code>--env</code><code>string</code> alias: --e

Environment to use for operations, and for selecting .env and .dev.vars files - <code>--env-file</code><code>string</code>Path to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files - <code>--install-skills</code><code>boolean</code> default: false

Install Cloudflare skills for detected AI coding agents before running the command - <code>--profile</code><code>string</code>Use a specific auth profile

</details>

r2 bucket delete

Delete an R2 bucket

npmyarnpnpm

npx wrangler r2 bucket delete <BUCKET>
yarn wrangler r2 bucket delete <BUCKET>
pnpm wrangler r2 bucket delete <BUCKET>
  • <BUCKET> string required

The name of the bucket to delete - --jurisdiction string alias: --J

The jurisdiction where the bucket exists

<details>

<summary>

Global flags

</summary>

  • <code>--v</code><code>boolean</code> alias: --version

Show version number - <code>--cwd</code><code>string</code>Run as if Wrangler was started in the specified directory instead of the current working directory - <code>--config</code><code>string</code> alias: --c

Path to Wrangler configuration file - <code>--env</code><code>string</code> alias: --e

Environment to use for operations, and for selecting .env and .dev.vars files - <code>--env-file</code><code>string</code>Path to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files - <code>--install-skills</code><code>boolean</code> default: false

Install Cloudflare skills for detected AI coding agents before running the command - <code>--profile</code><code>string</code>Use a specific auth profile

</details>

r2 bucket list

List R2 buckets

npmyarnpnpm

npx wrangler r2 bucket list
yarn wrangler r2 bucket list
pnpm wrangler r2 bucket list
  • --jurisdiction string alias: --J

The jurisdiction to list

<details>

<summary>

Global flags

</summary>

  • <code>--v</code><code>boolean</code> alias: --version

Show version number - <code>--cwd</code><code>string</code>Run as if Wrangler was started in the specified directory instead of the current working directory - <code>--config</code><code>string</code> alias: --c

Path to Wrangler configuration file - <code>--env</code><code>string</code> alias: --e

Environment to use for operations, and for selecting .env and .dev.vars files - <code>--env-file</code><code>string</code>Path to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files - <code>--install-skills</code><code>boolean</code> default: false

Install Cloudflare skills for detected AI coding agents before running the command - <code>--profile</code><code>string</code>Use a specific auth profile

</details>

Basin Catalog

Enable Basin Catalog on a bucket:

npmyarnpnpm

npx wrangler basin catalog enable <BUCKET_NAME>
yarn wrangler basin catalog enable <BUCKET_NAME>
pnpm wrangler basin catalog enable <BUCKET_NAME>

Disable Basin Catalog on a bucket:

npmyarnpnpm

npx wrangler basin catalog disable <BUCKET_NAME>
yarn wrangler basin catalog disable <BUCKET_NAME>
pnpm wrangler basin catalog disable <BUCKET_NAME>

Get the Basin Catalog status for a bucket:

npmyarnpnpm

npx wrangler basin catalog get <BUCKET_NAME>
yarn wrangler basin catalog get <BUCKET_NAME>
pnpm wrangler basin catalog get <BUCKET_NAME>

basin catalog compaction enable

Enable catalog-level compaction with a service token:

npmyarnpnpm

npx wrangler basin catalog compaction enable my-bucket --token <TOKEN>
yarn wrangler basin catalog compaction enable my-bucket --token <TOKEN>
pnpm wrangler basin catalog compaction enable my-bucket --token <TOKEN>

Enable table-level compaction:

npmyarnpnpm

npx wrangler basin catalog compaction enable my-bucket my-namespace my-table --target-size 256
yarn wrangler basin catalog compaction enable my-bucket my-namespace my-table --target-size 256
pnpm wrangler basin catalog compaction enable my-bucket my-namespace my-table --target-size 256

basin catalog compaction disable

Disable catalog-level compaction:

npmyarnpnpm

npx wrangler basin catalog compaction disable my-bucket
yarn wrangler basin catalog compaction disable my-bucket
pnpm wrangler basin catalog compaction disable my-bucket

Disable table-level compaction:

npmyarnpnpm

npx wrangler basin catalog compaction disable my-bucket my-namespace my-table
yarn wrangler basin catalog compaction disable my-bucket my-namespace my-table
pnpm wrangler basin catalog compaction disable my-bucket my-namespace my-table

Enable snapshot expiration:

npmyarnpnpm

npx wrangler basin catalog snapshot-expiration enable <BUCKET_NAME>
yarn wrangler basin catalog snapshot-expiration enable <BUCKET_NAME>
pnpm wrangler basin catalog snapshot-expiration enable <BUCKET_NAME>

Disable snapshot expiration:

npmyarnpnpm

npx wrangler basin catalog snapshot-expiration disable <BUCKET_NAME>
yarn wrangler basin catalog snapshot-expiration disable <BUCKET_NAME>
pnpm wrangler basin catalog snapshot-expiration disable <BUCKET_NAME>

r2 bucket cors set

Set the CORS configuration for an R2 bucket from a JSON file

npmyarnpnpm

npx wrangler r2 bucket cors set <BUCKET>
yarn wrangler r2 bucket cors set <BUCKET>
pnpm wrangler r2 bucket cors set <BUCKET>
  • <BUCKET> string required

The name of the R2 bucket to set the CORS configuration for - --file string required

Path to the JSON file containing the CORS configuration - --jurisdiction string alias: --J

The jurisdiction where the bucket exists - --force boolean alias: --ydefault: false

Skip confirmation

<details>

<summary>

Global flags

</summary>

  • <code>--v</code><code>boolean</code> alias: --version

Show version number - <code>--cwd</code><code>string</code>Run as if Wrangler was started in the specified directory instead of the current working directory - <code>--config</code><code>string</code> alias: --c

Path to Wrangler configuration file - <code>--env</code><code>string</code> alias: --e

Environment to use for operations, and for selecting .env and .dev.vars files - <code>--env-file</code><code>string</code>Path to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files - <code>--install-skills</code><code>boolean</code> default: false

Install Cloudflare skills for detected AI coding agents before running the command - <code>--profile</code><code>string</code>Use a specific auth profile

</details>

r2 bucket cors delete

Clear the CORS configuration for an R2 bucket

npmyarnpnpm

npx wrangler r2 bucket cors delete <BUCKET>
yarn wrangler r2 bucket cors delete <BUCKET>
pnpm wrangler r2 bucket cors delete <BUCKET>
  • <BUCKET> string required

The name of the R2 bucket to delete the CORS configuration for - --jurisdiction string alias: --J

The jurisdiction where the bucket exists - --force boolean alias: --ydefault: false

Skip confirmation

<details>

<summary>

Global flags

</summary>

  • <code>--v</code><code>boolean</code> alias: --version

Show version number - <code>--cwd</code><code>string</code>Run as if Wrangler was started in the specified directory instead of the current working directory - <code>--config</code><code>string</code> alias: --c

Path to Wrangler configuration file - <code>--env</code><code>string</code> alias: --e

Environment to use for operations, and for selecting .env and .dev.vars files - <code>--env-file</code><code>string</code>Path to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files - <code>--install-skills</code><code>boolean</code> default: false

Install Cloudflare skills for detected AI coding agents before running the command - <code>--profile</code><code>string</code>Use a specific auth profile

</details>

r2 bucket cors list

List the CORS rules for an R2 bucket

npmyarnpnpm

npx wrangler r2 bucket cors list <BUCKET>
yarn wrangler r2 bucket cors list <BUCKET>
pnpm wrangler r2 bucket cors list <BUCKET>
  • <BUCKET> string required

The name of the R2 bucket to list the CORS rules for - --jurisdiction string alias: --J

The jurisdiction where the bucket exists

<details>

<summary>

Global flags

</summary>

  • <code>--v</code><code>boolean</code> alias: --version

Show version number - <code>--cwd</code><code>string</code>Run as if Wrangler was started in the specified directory instead of the current working directory - <code>--config</code><code>string</code> alias: --c

Path to Wrangler configuration file - <code>--env</code><code>string</code> alias: --e

Environment to use for operations, and for selecting .env and .dev.vars files - <code>--env-file</code><code>string</code>Path to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files - <code>--install-skills</code><code>boolean</code> default: false

Install Cloudflare skills for detected AI coding agents before running the command - <code>--profile</code><code>string</code>Use a specific auth profile

</details>

r2 bucket dev-url enable

Enable public access via the r2.dev URL for an R2 bucket

npmyarnpnpm

npx wrangler r2 bucket dev-url enable <BUCKET>
yarn wrangler r2 bucket dev-url enable <BUCKET>
pnpm wrangler r2 bucket dev-url enable <BUCKET>
  • <BUCKET> string required

The name of the R2 bucket to enable public access via its r2.dev URL - --jurisdiction string alias: --J

The jurisdiction where the bucket exists - --force boolean alias: --ydefault: false

Skip confirmation

<details>

<summary>

Global flags

</summary>

  • <code>--v</code><code>boolean</code> alias: --version

Show version number - <code>--cwd</code><code>string</code>Run as if Wrangler was started in the specified directory instead of the current working directory - <code>--config</code><code>string</code> alias: --c

Path to Wrangler configuration file - <code>--env</code><code>string</code> alias: --e

Environment to use for operations, and for selecting .env and .dev.vars files - <code>--env-file</code><code>string</code>Path to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files - <code>--install-skills</code><code>boolean</code> default: false