wrangler命令 说明文档
1 | title: Commands - Wrangler · Cloudflare Workers docs |
Wrangler offers a number of commands to manage your Cloudflare Workers.
docs- Open this page in your default browser.init- Create a new project from a variety of web frameworks and templates.containers- Interact with Containers.d1- Interact with D1.vectorize- Interact with Vectorize indexes.hyperdrive- Manage your Hyperdrives.deploy- Deploy your Worker to Cloudflare.dev- Start a local server for developing your Worker.delete- Delete your Worker from Cloudflare.kv namespace- Manage Workers KV namespaces.kv key- Manage key-value pairs within a Workers KV namespace.kv bulk- Manage multiple key-value pairs within a Workers KV namespace in batches.r2 bucket- Manage Workers R2 buckets.r2 object- Manage Workers R2 objects.secret- Manage the secret variables for a Worker.secret bulk- Manage multiple secret variables for a Worker.secrets-store secret- Manage account secrets within a secrets store.secrets-store store- Manage your store within secrets store.workflows- Manage and configure Workflows.tail- Start a session to livestream logs from a deployed Worker.pages- Configure Cloudflare Pages.pipelines- Configure Cloudflare Pipelines.queues- Configure Workers Queues.login- Authorize Wrangler with your Cloudflare account using OAuth.logout- Remove Wrangler’s authorization for accessing your account.whoami- Retrieve your user information and test your authentication configuration.versions- Retrieve details for recent versions.deployments- Retrieve details for recent deployments.rollback- Rollback to a recent deployment.dispatch-namespace- Interact with a dispatch namespace.mtls-certificate- Manage certificates used for mTLS connections.cert- Manage certificates used for mTLS and Certificate Authority (CA) chain connections.types- Generate types from bindings and module rules in configuration.telemetry- Configure whether Wrangler can collect anonymous usage data.check- Validate your Worker.
Note
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
How to run Wrangler commands
This page provides a reference for Wrangler commands.
1 | wrangler <COMMAND> <SUBCOMMAND> [PARAMETERS] [OPTIONS] |
Since Cloudflare recommends installing Wrangler locally in your project(rather than globally), the way to run Wrangler will depend on your specific setup and package manager.
-
npm
1
npx wrangler <COMMAND> <SUBCOMMAND> [PARAMETERS] [OPTIONS]
-
yarn
1
yarn wrangler <COMMAND> <SUBCOMMAND> [PARAMETERS] [OPTIONS]
-
pnpm
1
pnpm wrangler <COMMAND> <SUBCOMMAND> [PARAMETERS] [OPTIONS]
You can add Wrangler commands that you use often as scripts in your project’s package.json file:
1 | { |
You can then run them using your package manager of choice:
-
npm
1
npm run deploy
-
yarn
1
yarn run deploy
-
pnpm
1
pnpm run deploy
docs
Open the Cloudflare developer documentation in your default browser.
1 | wrangler docs [<COMMAND>] |
COMMANDstring optional- The Wrangler command you want to learn more about. This opens your default browser to the section of the documentation that describes the command.
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
init
Create a new project via the create-cloudflare-cli (C3) tool. A variety of web frameworks are available to choose from as well as templates. Dependencies are installed by default, with the option to deploy your project immediately.
1 | wrangler init [<NAME>] [OPTIONS] |
-
NAMEstring optional (default: name of working directory)- The name of the Workers project. This is both the directory name and
nameproperty in the generated Wrangler configuration.
- The name of the Workers project. This is both the directory name and
-
--yesboolean optional- Answer yes to any prompts for new projects.
-
--from-dashstring optional- Fetch a Worker initialized from the dashboard. This is done by passing the flag and the Worker name.
wrangler init --from-dash <WORKER_NAME>. - The
--from-dashcommand will not automatically sync changes made to the dashboard after the command is used. Therefore, it is recommended that you continue using the CLI.
- Fetch a Worker initialized from the dashboard. This is done by passing the flag and the Worker name.
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
containers
Interact with Cloudflare’s Container Platform.
build
Build a Container image from a Dockerfile.
1 | wrangler containers build [PATH] [OPTIONS] |
PATHstring optional- Path for the directory containing the Dockerfile to build.
Options:
-
-t, --tagstring required- Name and optionally a tag (format: “name:tag”).
-
--path-to-dockerstring optional- Path to your docker binary if it’s not on $PATH.
- Default: “docker”
-
-p, --pushboolean optional- Push the built image to Cloudflare’s managed registry.
- Default: false
-
--platformstring optional- Platform to build for. Defaults to the architecture supported by Workers (linux/amd64).
- Default: “linux/amd64”
-
--jsonboolean optional- Return output as clean JSON.
- Default: false
delete
Delete a Container (application).
1 | wrangler containers delete <CONTAINER_ID> [OPTIONS] |
CONTAINER_IDstring required- The ID of the Container to delete.
-y, --skip-confirmationboolean optional- Skip deletion confirmation prompt.
--jsonboolean optional- Return output as JSON rather than a table.
images
Perform operations on images in your containers registry.
images list
List images in your containers registry.
1 | wrangler containers images list [OPTIONS] |
Options:
-
--filterstring optional- Regex to filter results.
-
--jsonboolean optional- Return output as clean JSON.
- Default: false
images delete
Remove an image from your containers registry.
1 | wrangler containers images delete [IMAGE] [OPTIONS] |
IMAGEstring required- Image to delete.
Options:
-
--jsonboolean optional- Return output as clean JSON.
- Default: false
info
Get information about a specific Container, including top-level details and a list of instances.
1 | wrangler containers info <CONTAINER_ID> [OPTIONS] |
CONTAINER_IDstring required- The ID of the Container to get information about.
--jsonboolean optional- Return output as JSON rather than a table.
list
List the Containers in your account.
1 | wrangler containers list [OPTIONS] |
--jsonboolean optional- Return output as JSON rather than a table.
push
Push a tagged image to a Cloudflare managed registry, which is automatically integrated with your account.
1 | wrangler containers push [TAG] [OPTIONS] |
TAGstring required- The name and tag of the container image to push.
Options:
-
--path-to-dockerstring optional- Path to your docker binary if it’s not on $PATH.
- Default: “docker”
-
--jsonboolean optional- Return output as clean JSON.
- Default: false
d1
Interact with Cloudflare’s D1 service.
create
Creates a new D1 database, and provides the binding and UUID that you will put in your Wrangler file.
1 | wrangler d1 create <DATABASE_NAME> [OPTIONS] |
-
DATABASE_NAMEstring required- The name of the new D1 database.
-
--locationstring optional- Provide an optional location hint for your database leader.
- Available options include
weur(Western Europe),eeur(Eastern Europe),apac(Asia Pacific),oc(Oceania),wnam(Western North America), andenam(Eastern North America).
info
Get information about a D1 database, including the current database size and state.
1 | wrangler d1 info <DATABASE_NAME> [OPTIONS] |
DATABASE_NAMEstring required- The name of the D1 database to get information about.
--jsonboolean optional- Return output as JSON rather than a table.
list
List all D1 databases in your account.
1 | wrangler d1 list [OPTIONS] |
--jsonboolean optional- Return output as JSON rather than a table.
delete
Delete a D1 database.
1 | wrangler d1 delete <DATABASE_NAME> [OPTIONS] |
DATABASE_NAMEstring required- The name of the D1 database to delete.
-y, --skip-confirmationboolean optional- Skip deletion confirmation prompt.
execute
Execute a query on a D1 database.
1 | wrangler d1 execute <DATABASE_NAME> [OPTIONS] |
Note
You must provide either --command or --file for this command to run successfully.
DATABASE_NAMEstring required- The name of the D1 database to execute a query on.
--commandstring optional- The SQL query you wish to execute.
--filestring optional- Path to the SQL file you wish to execute.
-y, --yesboolean optional- Answer
yesto any prompts.
- Answer
--localboolean (default: true) optional- Execute commands/files against a local database for use with wrangler dev.
--remoteboolean (default: false) optional- Execute commands/files against a remote D1 database for use with wrangler dev --remote.
--persist-tostring optional- Specify directory to use for local persistence (for use in combination with
--local).
- Specify directory to use for local persistence (for use in combination with
--jsonboolean optional- Return output as JSON rather than a table.
--previewboolean optional- Execute commands/files against a preview D1 database (as defined by
preview_database_idin the Wrangler configuration file).
- Execute commands/files against a preview D1 database (as defined by
export
Export a D1 database or table’s schema and/or content to a .sql file.
1 | wrangler d1 export <DATABASE_NAME> [OPTIONS] |
DATABASE_NAMEstring required- The name of the D1 database to export.
--localboolean (default: true) optional- Export from a local database for use with wrangler dev.
--remoteboolean (default: false) optional- Export from a remote D1 database for use with wrangler dev --remote.
--outputstring required- Path to the SQL file for your export.
--tablestring optional- The name of the table within a D1 database to export.
--no-databoolean (default: false) optional- Controls whether export SQL file contains database data. Note that
--no-data=trueis not recommended due to a known wrangler limitation that intreprets the value as false.
- Controls whether export SQL file contains database data. Note that
--no-schemaboolean (default: false) optional- Controls whether export SQL file contains database schema. Note that
--no-schema=trueis not recommended due to a known wrangler limitation that intreprets the value as false.
- Controls whether export SQL file contains database schema. Note that
time-travel restore
Restore a database to a specific point-in-time using Time Travel.
1 | wrangler d1 time-travel restore <DATABASE_NAME> [OPTIONS] |
DATABASE_NAMEstring required- The name of the D1 database to execute a query on.
--bookmarkstring optional- A D1 bookmark representing the state of a database at a specific point in time.
--timestampstring optional- A UNIX timestamp or JavaScript date-time
stringwithin the last 30 days.
- A UNIX timestamp or JavaScript date-time
--jsonboolean optional- Return output as JSON rather than a table.
time-travel info
Inspect the current state of a database for a specific point-in-time using Time Travel.
1 | wrangler d1 time-travel info <DATABASE_NAME> [OPTIONS] |
DATABASE_NAMEstring required- The name of the D1 database to execute a query on.
--timestampstring optional- A UNIX timestamp or JavaScript date-time
stringwithin the last 30 days.
- A UNIX timestamp or JavaScript date-time
--jsonbboolean optional- Return output as JSON rather than a table.
migrations create
Create a new migration.
This will generate a new versioned file inside the migrations folder. Name your migration file as a description of your change. This will make it easier for you to find your migration in the migrations folder. An example filename looks like:
0000_create_user_table.sql
The filename will include a version number and the migration name you specify below.
1 | wrangler d1 migrations create <DATABASE_NAME> <MIGRATION_NAME> |
DATABASE_NAMEstring required- The name of the D1 database you wish to create a migration for.
MIGRATION_NAMEstring required- A descriptive name for the migration you wish to create.
migrations list
View a list of unapplied migration files.
1 | wrangler d1 migrations list <DATABASE_NAME> [OPTIONS] |
DATABASE_NAMEstring required- The name of the D1 database you wish to list unapplied migrations for.
--localboolean optional- Show the list of unapplied migration files on your locally persisted D1 database.
--remoteboolean (default: false) optional- Show the list of unapplied migration files on your remote D1 database.
--persist-tostring optional- Specify directory to use for local persistence (for use in combination with
--local).
- Specify directory to use for local persistence (for use in combination with
--previewboolean optional- Show the list of unapplied migration files on your preview D1 database (as defined by
preview_database_idin the Wrangler configuration file).
- Show the list of unapplied migration files on your preview D1 database (as defined by
migrations apply
Apply any unapplied migrations.
This command will prompt you to confirm the migrations you are about to apply. Confirm that you would like to proceed. After, a backup will be captured.
The progress of each migration will be printed in the console.
When running the apply command in a CI/CD environment or another non-interactive command line, the confirmation step will be skipped, but the backup will still be captured.
If applying a migration results in an error, this migration will be rolled back, and the previous successful migration will remain applied.
1 | wrangler d1 migrations apply <DATABASE_NAME> [OPTIONS] |
DATABASE_NAMEstring required- The name of the D1 database you wish to apply your migrations on.
--envstring optional- Specify which environment configuration to use for D1 binding
--localboolean (default: true) optional- Execute any unapplied migrations on your locally persisted D1 database.
--remoteboolean (default: false) optional- Execute any unapplied migrations on your remote D1 database.
--persist-tostring optional- Specify directory to use for local persistence (for use in combination with
--local).
- Specify directory to use for local persistence (for use in combination with
--previewboolean optional- Execute any unapplied migrations on your preview D1 database (as defined by
preview_database_idin the Wrangler configuration file).
- Execute any unapplied migrations on your preview D1 database (as defined by
hyperdrive
Manage Hyperdrive database configurations.
create
Create a new Hyperdrive configuration.
1 | wrangler hyperdrive create <CONFIG_NAME> [OPTIONS] |
CONFIG_NAMEstring required- The name of the Hyperdrive configuration to create.
--connection-stringstring optional- The database connection string in the form
postgres://user:password@hostname:port/database.
- The database connection string in the form
--origin-hoststring optional- The hostname or IP address Hyperdrive should connect to.
--origin-portnumber optional- The database port to connect to.
--origin-schemestring optional- The scheme used to connect to the origin database, for example, postgresql or postgres.
--databasestring optional- The database (name) to connect to. For example, Postgres or defaultdb.
--origin-userstring optional- The username used to authenticate to the database.
--origin-passwordstring optional- The password used to authenticate to the database.
--access-client-idstring optional- The Client ID of the Access token to use when connecting to the origin database, must be set with a Client Access Secret. Mutually exclusive with
origin-port.
- The Client ID of the Access token to use when connecting to the origin database, must be set with a Client Access Secret. Mutually exclusive with
--access-client-secretstring optional- The Client Secret of the Access token to use when connecting to the origin database, must be set with a Client Access ID. Mutually exclusive with
origin-port.
- The Client Secret of the Access token to use when connecting to the origin database, must be set with a Client Access ID. Mutually exclusive with
--caching-disabledboolean optional- Disables the caching of SQL responses.
--max-agenumber optional- Specifies max duration for which items should persist in the cache, cannot be set when caching is disabled.
--swrnumber optional- Stale While Revalidate - Indicates the number of seconds cache may serve the response after it becomes stale, cannot be set when caching is disabled.
--ca-certificate-idstring optional- Sets custom CA certificate when connecting to origin database.
--mtls-certificate-idstring optional- Sets custom mTLS client certificates when connecting to origin database.
--sslmodestring optional- Sets SSL mode for CA verification. Must be
require|verify-ca|verify-full.
- Sets SSL mode for CA verification. Must be
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
update
Update an existing Hyperdrive configuration.
1 | wrangler hyperdrive update <ID> [OPTIONS] |
IDstring required- The ID of the Hyperdrive configuration to update.
--namestring optional- The new name of the Hyperdrive configuration.
--connection-stringstring optional- The database connection string in the form
postgres://user:password@hostname:port/database.
- The database connection string in the form
--origin-hoststring optional- The new database hostname or IP address Hyperdrive should connect to.
--origin-portstring optional- The new database port to connect to.
--origin-schemestring optional- The scheme used to connect to the origin database, for example, postgresql or postgres.
--databasestring optional- The new database (name) to connect to. For example, Postgres or defaultdb.
--origin-userstring optional- The new username used to authenticate to the database.
--origin-passwordstring optional- The new password used to authenticate to the database.
--access-client-idstring optional- The Client ID of the Access token to use when connecting to the origin database, must be set with a Client Access Secret. Mutually exclusive with
origin-port.
- The Client ID of the Access token to use when connecting to the origin database, must be set with a Client Access Secret. Mutually exclusive with
--access-client-secretstring optional- The Client Secret of the Access token to use when connecting to the origin database, must be set with a Client Access ID. Mutually exclusive with
origin-port.
- The Client Secret of the Access token to use when connecting to the origin database, must be set with a Client Access ID. Mutually exclusive with
--caching-disabledboolean optional- Disables the caching of SQL responses.
--max-agenumber optional- Specifies max duration for which items should persist in the cache, cannot be set when caching is disabled.
--swrnumber optional- Stale While Revalidate - Indicates the number of seconds cache may serve the response after it becomes stale, cannot be set when caching is disabled.
--ca-certificate-idstring optional- Sets custom CA certificate when connecting to origin database.
--mtls-certificate-idstring optional- Sets custom mTLS client certificates when connecting to origin database.
--sslmodestring optional- Sets SSL mode for CA verification. Must be
require|verify-ca|verify-full.
- Sets SSL mode for CA verification. Must be
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
list
List all Hyperdrive configurations.
1 | wrangler hyperdrive list |
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
delete
Delete an existing Hyperdrive configuration.
1 | wrangler hyperdrive delete <ID> |
IDstring required- The name of the Hyperdrive configuration to delete.
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
get
Get an existing Hyperdrive configuration.
1 | wrangler hyperdrive get <ID> |
IDstring required- The name of the Hyperdrive configuration to get.
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
vectorize
Interact with a Vectorize vector database.
create
Creates a new vector index, and provides the binding and name that you will put in your Wrangler file.
1 | npx wrangler vectorize create <INDEX_NAME> [--dimensions=<NUM_DIMENSIONS>] [--metric=<DISTANCE_METRIC>] [--description=<DESCRIPTION>] |
INDEX_NAMEstring required- The name of the new index to create. Must be unique for an account and cannot be changed after creation.
--dimensionsnumber required- The vector dimension width to configure the index for. Cannot be changed after creation.
--metricstring required- The distance metric to use for calculating vector distance. Must be one of
cosine,euclidean, ordot-product.
- The distance metric to use for calculating vector distance. Must be one of
--descriptionstring optional- A description for your index.
--deprecated-v1boolean optional- Create a legacy Vectorize index. Please note that legacy Vectorize indexes are on a deprecation path.
list
List all Vectorize indexes in your account, including the configured dimensions and distance metric.
1 | npx wrangler vectorize list |
--deprecated-v1boolean optional- List legacy Vectorize indexes. Please note that legacy Vectorize indexes are on a deprecation path.
get
Get details about an individual index, including its configuration.
1 | npx wrangler vectorize get <INDEX_NAME> |
INDEX_NAMEstring required- The name of the index to fetch details for.
--deprecated-v1boolean optional- Get a legacy Vectorize index. Please note that legacy Vectorize indexes are on a deprecation path.
info
Get some additional information about an individual index, including the vector count and details about the last processed mutation.
1 | npx wrangler vectorize info <INDEX_NAME> |
INDEX_NAMEstring required- The name of the index to fetch details for.
delete
Delete a Vectorize index.
1 | npx wrangler vectorize delete <INDEX_NAME> [OPTIONS] |
INDEX_NAMEstring required- The name of the Vectorize index to delete.
--forceboolean optional- Skip confirmation when deleting the index (Note: This is not a recoverable operation).
--deprecated-v1boolean optional- Delete a legacy Vectorize index. Please note that legacy Vectorize indexes are on a deprecation path.
insert
Insert vectors into an index.
1 | npx wrangler vectorize insert <INDEX_NAME> [OPTIONS] |
INDEX_NAMEstring required- The name of the Vectorize index to upsert vectors in.
--filestring required- A file containing the vectors to insert in newline-delimited JSON (JSON) format.
--batch-sizenumber optional- The number of vectors to insert at a time (default:
1000).
- The number of vectors to insert at a time (default:
--deprecated-v1boolean optional- Insert into a legacy Vectorize index. Please note that legacy Vectorize indexes are on a deprecation path.
upsert
Upsert vectors into an index. Existing vectors in the index would be overwritten.
1 | npx wrangler vectorize upsert <INDEX_NAME> [OPTIONS] |
INDEX_NAMEstring required- The name of the Vectorize index to upsert vectors in.
--filestring required- A file containing the vectors to insert in newline-delimited JSON (JSON) format.
--batch-sizenumber optional- The number of vectors to insert at a time (default:
5000).
- The number of vectors to insert at a time (default:
query
Query a Vectorize index for similar vectors.
1 | npx wrangler vectorize query <INDEX_NAME> [OPTIONS] |
INDEX_NAMEstring required- The name of the Vectorize index to query.
--vectorarray optional- Vector against which the Vectorize index is queried. Either this or the
vector-idparam must be provided.
- Vector against which the Vectorize index is queried. Either this or the
--vector-idstring optional- Identifier for a vector that is already present in the index against which the index is queried. Either this or the
vectorparam must be provided.
- Identifier for a vector that is already present in the index against which the index is queried. Either this or the
--top-knumber optional- The number of vectors to query (default:
5).
- The number of vectors to query (default:
--return-valuesboolean optional- Enable to return vector values in the response (default:
false).
- Enable to return vector values in the response (default:
--return-metadatastring optional- Enable to return vector metadata in the response. Must be one of
none,indexed, orall(default:none).
- Enable to return vector metadata in the response. Must be one of
--namespacestring optional- Query response to only include vectors from this namespace.
--filterstring optional- Filter vectors based on this metadata filter. Example:
'{ 'p1': 'abc', 'p2': { '$ne': true }, 'p3': 10, 'p4': false, 'nested.p5': 'abcd' }'
- Filter vectors based on this metadata filter. Example:
get-vectors
Fetch vectors from a Vectorize index using the provided ids.
1 | npx wrangler vectorize get-vectors <INDEX_NAME> [OPTIONS] |
INDEX_NAMEstring required- The name of the Vectorize index from which vectors need to be fetched.
--idsarray required- List of ids for which vectors must be fetched.
delete-vectors
Delete vectors in a Vectorize index using the provided ids.
1 | npx wrangler vectorize delete-vectors <INDEX_NAME> [OPTIONS] |
INDEX_NAMEstring required- The name of the Vectorize index from which vectors need to be deleted.
--idsarray required- List of ids corresponding to the vectors that must be deleted.
create-metadata-index
Enable metadata filtering on the specified property.
1 | npx wrangler vectorize create-metadata-index <INDEX_NAME> [OPTIONS] |
INDEX_NAMEstring required- The name of the Vectorize index for which metadata index needs to be created.
--property-namestring required- Metadata property for which metadata filtering should be enabled.
--typestring required- Data type of the property. Must be one of
string,number, orboolean.
- Data type of the property. Must be one of
list-metadata-index
List metadata properties on which metadata filtering is enabled.
1 | npx wrangler vectorize list-metadata-index <INDEX_NAME> [OPTIONS] |
INDEX_NAMEstring required- The name of the Vectorize index for which metadata indexes needs to be fetched.
delete-metadata-index
Disable metadata filtering on the specified property.
1 | npx wrangler vectorize delete-metadata-index <INDEX_NAME> [OPTIONS] |
INDEX_NAMEstring required- The name of the Vectorize index for which metadata index needs to be disabled.
--property-namestring required- Metadata property for which metadata filtering should be disabled.
dev
Start a local server for developing your Worker.
1 | wrangler dev [<SCRIPT>] [OPTIONS] |
Note
None of the options for this command are required. Many of these options can be set in your Wrangler file. Refer to the Wrangler configuration documentation for more information.
-
SCRIPTstring- The path to an entry point for your Worker. Only required if your Wrangler configuration file does not include a
mainkey (for example,main = "index.js").
- The path to an entry point for your Worker. Only required if your Wrangler configuration file does not include a
-
--namestring optional- Name of the Worker.
-
--config,-cstring[] optional- Path(s) to Wrangler configuration file. If not provided, Wrangler will use the nearest config file based on your current working directory.
- You can provide multiple configuration files to run multiple Workers in one dev session like this:
wrangler dev -c ./wrangler.toml -c ../other-worker/wrangler.toml. The first config will be treated as the primary Worker, which will be exposed over HTTP. The remaining config files will only be accessible via a service binding from the primary Worker.
-
--no-bundleboolean (default: false) optional- Skip Wrangler’s build steps. Particularly useful when using custom builds. Refer to Bundling for more information.
-
--envstring optional- Perform on a specific environment.
-
--compatibility-datestring optional- A date in the form yyyy-mm-dd, which will be used to determine which version of the Workers runtime is used.
-
--compatibility-flags,--compatibility-flagstring[] optional- Flags to use for compatibility checks.
-
--latestboolean (default: true) optional- Use the latest version of the Workers runtime.
-
--ipstring optional- IP address to listen on, defaults to
localhost.
- IP address to listen on, defaults to
-
--portnumber optional- Port to listen on.
-
--inspector-portnumber optional- Port for devtools to connect to.
-
--routes,--routestring[] optional- Routes to upload.
- For example:
--route example.com/*.
-
--hoststring optional- Host to forward requests to, defaults to the zone of project.
-
--local-protocol‘http’|‘https’ (default: http) optional- Protocol to listen to requests on.
-
--https-key-pathstring optional- Path to a custom certificate key.
-
--https-cert-pathstring optional- Path to a custom certificate.
-
--local-upstreamstring optional- Host to act as origin in local mode, defaults to
dev.hostor route.
- Host to act as origin in local mode, defaults to
-
--assetsstring optional beta- Folder of static assets to be served. Replaces Workers Sites. Visit assets for more information.
-
--sitestring optional deprecated, use `–assets`-
Folder of static assets for Workers Sites.
Warning
Workers Sites is deprecated. Please use Workers Assets or Pages.
-
-
--site-includestring[] optional deprecated- Array of
.gitignore-style patterns that match file or directory names from the sites directory. Only matched items will be uploaded.
- Array of
-
--site-excludestring[] optional deprecated- Array of
.gitignore-style patterns that match file or directory names from the sites directory. Matched items will not be uploaded.
- Array of
-
--upstream-protocol‘http’|‘https’ (default: https) optional- Protocol to forward requests to host on.
-
--varkey:value\[] optional- Array of
key:valuepairs to inject as variables into your code. The value will always be passed as a string to your Worker. - For example,
--var "git_hash:'$(git rev-parse HEAD)'" "test:123"makes thegit_hashandtestvariables available in your Worker’senv. - This flag is an alternative to defining
varsin your Wrangler configuration file. If defined in both places, this flag’s values will be used.
- Array of
-
--definekey:value\[] optional- Array of
key:valuepairs to replace global identifiers in your code. - For example,
--define "GIT_HASH:'$(git rev-parse HEAD)'"will replace all uses ofGIT_HASHwith the actual value at build time. - This flag is an alternative to defining
definein your Wrangler configuration file. If defined in both places, this flag’s values will be used.
- Array of
-
--tsconfigstring optional- Path to a custom
tsconfig.jsonfile.
- Path to a custom
-
--minifyboolean optional- Minify the Worker.
-
--persist-tostring optional- Specify directory to use for local persistence.
-
--remoteboolean (default: false) optional- Develop against remote resources and data stored on Cloudflare’s network.
-
--test-scheduledboolean (default: false) optional- Exposes a
/__scheduledfetch route which will trigger a scheduled event (Cron Trigger) for testing during development. To simulate different cron patterns, acronquery parameter can be passed in:/__scheduled?cron=*+*+*+*+*or/cdn-cgi/handler/scheduled?cron=*+*+*+*+*.
- Exposes a
-
--log-level‘debug’|‘info’|‘log’|‘warn’|'error|‘none’ (default: log) optional- Specify Wrangler’s logging level.
-
--show-interactive-dev-sessionboolean (default: true if the terminal supports interactivity) optional- Show the interactive dev session.
-
--aliasArray<string>- Specify modules to alias using module aliasing.
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
wrangler dev is a way to locally test your Worker while developing. With wrangler dev running, send HTTP requests to localhost:8787 and your Worker should execute as expected. You will also see console.log messages and exceptions appearing in your terminal.
deploy
Deploy your Worker to Cloudflare.
1 | wrangler deploy [<SCRIPT>] [OPTIONS] |
Note
None of the options for this command are required. Also, many can be set in your Wrangler file. Refer to the Wrangler configuration documentation for more information.
-
SCRIPTstring- The path to an entry point for your Worker. Only required if your Wrangler configuration file does not include a
mainkey (for example,main = "index.js").
- The path to an entry point for your Worker. Only required if your Wrangler configuration file does not include a
-
--namestring optional- Name of the Worker.
-
--no-bundleboolean (default: false) optional- Skip Wrangler’s build steps. Particularly useful when using custom builds. Refer to Bundling for more information.
-
--envstring optional-
Perform on a specific environment.
Note
If you’re using the Cloudflare Vite plugin, you select the environment at dev or build time via the
CLOUDFLARE_ENVenvironment variable rather than the--envflag. Otherwise, environments are defined in your Worker config file as usual. For more detail on using environments with the Cloudflare Vite plugin, refer to the plugin documentation.
-
-
--outdirstring optional- Path to directory where Wrangler will write the bundled Worker files.
-
--compatibility-datestring optional- A date in the form yyyy-mm-dd, which will be used to determine which version of the Workers runtime is used.
-
--compatibility-flags,--compatibility-flagstring[] optional- Flags to use for compatibility checks.
-
--latestboolean (default: true) optional- Use the latest version of the Workers runtime.
-
--assetsstring optional beta- Folder of static assets to be served. Replaces Workers Sites. Visit assets for more information.
-
--sitestring optional deprecated, use `–assets`-
Folder of static assets for Workers Sites.
Warning
Workers Sites is deprecated. Please use Workers Assets or Pages.
-
-
--site-includestring[] optional deprecated- Array of
.gitignore-style patterns that match file or directory names from the sites directory. Only matched items will be uploaded.
- Array of
-
--site-excludestring[] optional deprecated- Array of
.gitignore-style patterns that match file or directory names from the sites directory. Matched items will not be uploaded.
- Array of
-
--varkey:value\[] optional- Array of
key:valuepairs to inject as variables into your code. The value will always be passed as a string to your Worker. - For example,
--var git_hash:$(git rev-parse HEAD) test:123makes thegit_hashandtestvariables available in your Worker’senv. - This flag is an alternative to defining
varsin your Wrangler configuration file. If defined in both places, this flag’s values will be used.
- Array of
-
--definekey:value\[] optional- Array of
key:valuepairs to replace global identifiers in your code. - For example,
--define GIT_HASH:$(git rev-parse HEAD)will replace all uses ofGIT_HASHwith the actual value at build time. - This flag is an alternative to defining
definein your Wrangler configuration file. If defined in both places, this flag’s values will be used.
- Array of
-
--triggers,--schedule,--schedulesstring[] optional- Cron schedules to attach to the deployed Worker. Refer to Cron Trigger Examples.
-
--routes,--routestring[] optional- Routes where this Worker will be deployed.
- For example:
--route example.com/*.
-
--tsconfigstring optional- Path to a custom
tsconfig.jsonfile.
- Path to a custom
-
--minifyboolean optional- Minify the bundled Worker before deploying.
-
--dry-runboolean (default: false) optional- Compile a project without actually deploying to live servers. Combined with
--outdir, this is also useful for testing the output ofnpx wrangler deploy. It also gives developers a chance to upload our generated sourcemap to a service like Sentry, so that errors from the Worker can be mapped against source code, but before the service goes live.
- Compile a project without actually deploying to live servers. Combined with
-
--keep-varsboolean (default: false) optional- It is recommended best practice to treat your Wrangler developer environment as a source of truth for your Worker configuration, and avoid making changes via the Cloudflare dashboard.
- If you change your environment variables in the Cloudflare dashboard, Wrangler will override them the next time you deploy. If you want to disable this behaviour set
keep-varstotrue. - Secrets are never deleted by a deployment whether this flag is true or false.
-
--dispatch-namespacestring optional- Specify the Workers for Platforms dispatch namespace to upload this Worker to.
-
--metafilestring optional- Specify a file to write the build metadata from esbuild to. If flag is used without a path string, this defaults to
bundle-meta.jsoninside the directory specified by--outdir. This can be useful for understanding the bundle size.
- Specify a file to write the build metadata from esbuild to. If flag is used without a path string, this defaults to
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
delete
Delete your Worker and all associated Cloudflare developer platform resources.
1 | wrangler delete [<SCRIPT>] [OPTIONS] |
SCRIPTstring- The path to an entry point for your Worker. Only required if your Wrangler configuration file does not include a
mainkey (for example,main = "index.js").
- The path to an entry point for your Worker. Only required if your Wrangler configuration file does not include a
--namestring optional- Name of the Worker.
--envstring optional- Perform on a specific environment.
--dry-runboolean (default: false) optional- Do not actually delete the Worker. This is useful for testing the output of
wrangler delete.
- Do not actually delete the Worker. This is useful for testing the output of
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
kv namespace
Manage Workers KV namespaces.
Note
The kv ... commands allow you to manage your Workers KV resources in the Cloudflare network. Learn more about using Workers KV with Wrangler in the Workers KV guide.
Warning
Since version 3.60.0, Wrangler supports the kv ... syntax. If you are using versions below 3.60.0, the command follows the kv:... syntax. Learn more about the deprecation of the kv:... syntax in the Wrangler commands for KV page.
create
Create a new namespace.
1 | wrangler kv namespace create <NAMESPACE> [OPTIONS] |
NAMESPACEstring required- The name of the new namespace.
--envstring optional- Perform on a specific environment.
--previewboolean optional- Interact with a preview namespace (the
preview_idvalue).
- Interact with a preview namespace (the
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
The following is an example of using the create command to create a KV namespace called MY_KV.
1 | npx wrangler kv namespace create "MY_KV" |
1 | 🌀 Creating namespace with title "worker-MY_KV" |
The following is an example of using the create command to create a preview KV namespace called MY_KV.
1 | npx wrangler kv namespace create "MY_KV" --preview |
1 | 🌀 Creating namespace with title "my-site-MY_KV_preview" |
list
List all KV namespaces associated with the current account ID.
1 | wrangler kv namespace list |
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
The following is an example that passes the Wrangler command through the jq command:
1 | npx wrangler kv namespace list | jq "." |
1 | [ |
delete
Delete a given namespace.
1 | wrangler kv namespace delete {--binding=<BINDING>|--namespace-id=<NAMESPACE_ID>} [OPTIONS] |
Warning
This command requires --binding or --namespace-id.
--bindingstring- The binding name of the namespace, as stored in the Wrangler file, to delete.
--namespace-idstring- The ID of the namespace to delete.
--envstring optional- Perform on a specific environment.
--previewboolean optional- Interact with a preview namespace instead of production.
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
The following is an example of deleting a KV namespace called MY_KV.
1 | npx wrangler kv namespace delete --binding=MY_KV |
1 | Are you sure you want to delete namespace f7b02e7fc70443149ac906dd81ec1791? [y/n] |
The following is an example of deleting a preview KV namespace called MY_KV.
1 | npx wrangler kv namespace delete --binding=MY_KV --preview |
1 | Are you sure you want to delete namespace 15137f8edf6c09742227e99b08aaf273? [y/n] |
kv key
Manage key-value pairs within a Workers KV namespace.
Note
The kv ... commands allow you to manage your Workers KV resources in the Cloudflare network. Learn more about using Workers KV with Wrangler in the Workers KV guide.
Warning
Since version 3.60.0, Wrangler supports the kv ... syntax. If you are using versions below 3.60.0, the command follows the kv:... syntax. Learn more about the deprecation of the kv:... syntax in the Wrangler commands for KV page.
put
Write a single key-value pair to a particular namespace.
1 | wrangler kv key put <KEY> {<VALUE>|--path=<PATH>} {--binding=<BINDING>|--namespace-id=<NAMESPACE_ID>} [OPTIONS] |
Warning
This command requires a VALUE or --path.
This command requires a --binding or --namespace-id flag.
KEYstring required- The key to write to.
VALUEstring optional- The value to write.
--pathoptional- When defined, the value is loaded from the file at
--pathrather than reading it from theVALUEargument. This is ideal for security-sensitive operations because it avoids saving keys and values into your terminal history.
- When defined, the value is loaded from the file at
--bindingstring- The binding name of the namespace, as stored in the Wrangler file, to write to.
--namespace-idstring- The ID of the namespace to write to.
--envstring optional- Perform on a specific environment.
--previewboolean optional- Interact with a preview namespace instead of production.
--ttlnumber optional- The lifetime (in number of seconds) that the key-value pair should exist before expiring. Must be at least
60seconds. This option takes precedence over theexpirationoption.
- The lifetime (in number of seconds) that the key-value pair should exist before expiring. Must be at least
--expirationnumber optional- The timestamp, in UNIX seconds, indicating when the key-value pair should expire.
--metadatastring optional- Any (escaped) JSON serialized arbitrary object to a maximum of 1024 bytes.
--localboolean (default: true) optional- Interact with locally persisted data.
--remoteboolean (default: false) optional- Interact with remote storage.
--persist-tostring optional- Specify directory for locally persisted data.
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
The following is an example that puts a key-value into the namespace with binding name of MY_KV.
1 | npx wrangler kv key put --binding=MY_KV "my-key" "some-value" |
1 | Writing the value "some-value" to key "my-key" on namespace f7b02e7fc70443149ac906dd81ec1791. |
The following is an example that puts a key-value into the preview namespace with binding name of MY_KV.
1 | npx wrangler kv key put --binding=MY_KV --preview "my-key" "some-value" |
1 | Writing the value "some-value" to key "my-key" on namespace 15137f8edf6c09742227e99b08aaf273. |
The following is an example that puts a key-value into a namespace, with a time-to-live value of 10000 seconds.
1 | npx wrangler kv key put --binding=MY_KV "my-key" "some-value" --ttl=10000 |
1 | Writing the value "some-value" to key "my-key" on namespace f7b02e7fc70443149ac906dd81ec1791. |
The following is an example that puts a key-value into a namespace, where the value is read from the value.txt file.
1 | npx wrangler kv key put --binding=MY_KV "my-key" --path=value.txt |
1 | Writing the contents of value.txt to the key "my-key" on namespace f7b02e7fc70443149ac906dd81ec1791. |
list
Output a list of all keys in a given namespace.
1 | wrangler kv key list {--binding=<BINDING>|--namespace-id=<NAMESPACE_ID>} [OPTIONS] |
Warning
This command requires --binding or --namespace-id.
--bindingstring- The binding name of the namespace, as stored in the Wrangler file, to list from.
--namespace-idstring- The ID of the namespace to list from.
--envstring optional- Perform on a specific environment.
--previewboolean optional- Interact with a preview namespace instead of production.
--prefixstring optional- Only list keys that begin with the given prefix.
--localboolean (default: true) optional- Interact with locally persisted data.
--remoteboolean (default: false) optional- Interact with remote storage.
--persist-tostring optional- Specify directory for locally persisted data.
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
Below is an example that passes the Wrangler command through the jq command:
1 | npx wrangler kv key list --binding=MY_KV --prefix="public" | jq "." |
1 | [ |
get
Read a single value by key from the given namespace.
1 | wrangler kv key get <KEY> {--binding=<BINDING>|--namespace-id=<NAMESPACE_ID>} [OPTIONS] |
Warning
Exactly one of --binding or --namespace-id is required.
KEYstring required- The key value to get.
--bindingstring- The binding name of the namespace, as stored in the Wrangler file, to get from.
--namespace-idstring- The ID of the namespace to get from.
--envstring optional- Perform on a specific environment.
--previewboolean optional- Interact with a preview namespace instead of production.
--textboolean optional- Decode the returned value as a UTF-8 string.
--localboolean (default: true) optional- Interact with locally persisted data.
--remoteboolean (default: false) optional- Interact with remote storage.
--persist-tostring optional- Specify directory for locally persisted data.
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
The following is an example that gets the value of the "my-key" key from the KV namespace with binding name MY_KV.
1 | npx wrangler kv key get --binding=MY_KV "my-key" |
1 | value |
delete
Remove a single key value pair from the given namespace.
1 | wrangler kv key delete <KEY> {--binding=<BINDING>|--namespace-id=<NAMESPACE_ID>} [OPTIONS] |
Warning
Exactly one of --binding or --namespace-id is required.
KEYstring required- The key value to get.
--bindingstring- The binding name of the namespace, as stored in the Wrangler file, to delete from.
--namespace-idstring- The ID of the namespace to delete from.
--envstring optional- Perform on a specific environment.
--previewboolean optional- Interact with a preview namespace instead of production.
--localboolean (default: true) optional- Interact with locally persisted data.
--remoteboolean (default: false) optional- Interact with remote storage.
--persist-tostring optional- Specify directory for locally persisted data.
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
The following is an example that deletes the key-value pair with key "my-key" from the KV namespace with binding name MY_KV.
1 | npx wrangler kv key delete --binding=MY_KV "my-key" |
1 | Deleting the key "my-key" on namespace f7b02e7fc70443149ac906dd81ec1791. |
kv bulk
Manage multiple key-value pairs within a Workers KV namespace in batches.
Note
The kv ... commands allow you to manage your Workers KV resources in the Cloudflare network. Learn more about using Workers KV with Wrangler in the Workers KV guide.
Warning
Since version 3.60.0, Wrangler supports the kv ... syntax. If you are using versions below 3.60.0, the command follows the kv:... syntax. Learn more about the deprecation of the kv:... syntax in the Wrangler commands for KV page.
put
Write a JSON file containing an array of key-value pairs to the given namespace.
1 | wrangler kv bulk put <FILENAME> {--binding=<BINDING>|--namespace-id=<NAMESPACE_ID>} [OPTIONS] |
Warning
This command requires --binding or --namespace-id.
FILENAMEstring required- The JSON file containing an array of key-value pairs to write to the namespace.
--bindingstring- The binding name of the namespace, as stored in the Wrangler file, to write to.
--namespace-idstring- The ID of the namespace to write to.
--envstring optional- Perform on a specific environment.
--previewboolean optional- Interact with a preview namespace instead of production.
--localboolean (default: true) optional- Interact with locally persisted data.
--remoteboolean (default: false) optional- Interact with remote storage.
--persist-tostring optional- Specify directory for locally persisted data.
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
This command takes a JSON file as an argument with a list of key-value pairs to upload. An example of JSON input:
1 | [ |
KV namespace values can only store strings. In order to save complex a value, stringify it to JSON:
1 | [ |
Refer to the full schema for key-value entries uploaded via the bulk API:
keystring required- The key’s name. The name may be 512 bytes maximum. All printable, non-whitespace characters are valid.
valuestring required- The UTF-8 encoded string to be stored, up to 25 MB in length.
metadataobject optional- Any arbitrary object (must serialize to JSON) to a maximum of 1,024 bytes.
expirationnumber optional- The time, measured in number of seconds since the UNIX epoch, at which the key should expire.
expiration_ttlnumber optional- The number of seconds the document should exist before expiring. Must be at least
60seconds.
- The number of seconds the document should exist before expiring. Must be at least
base64boolean optional- When true, the server will decode the value as base64 before storing it. This is useful for writing values that would otherwise be invalid JSON strings, such as images. Defaults to
false.
- When true, the server will decode the value as base64 before storing it. This is useful for writing values that would otherwise be invalid JSON strings, such as images. Defaults to
Note
If both expiration and expiration_ttl are specified for a given key, the API will prefer expiration_ttl.
The following is an example of writing all the key-value pairs found in the allthethingsupload.json file.
1 | npx wrangler kv bulk put --binding=MY_KV allthethingsupload.json |
1 | Success! |
delete
Delete all keys read from a JSON file within a given namespace.
1 | wrangler kv bulk delete <FILENAME> {--binding=<BINDING>|--namespace-id=<NAMESPACE_ID>} [OPTIONS] |
Warning
This command requires --binding or --namespace-id.
FILENAMEstring required- The JSON file containing an array of keys to delete from the namespace.
--bindingstring- The binding name of the namespace, as stored in the Wrangler file, to delete from.
--namespace-idstring- The ID of the namespace to delete from.
--envstring optional- Perform on a specific environment.
--previewboolean optional- Interact with a preview namespace instead of production.
--localboolean (default: true) optional- Interact with locally persisted data.
--remoteboolean (default: false) optional- Interact with remote storage.
--persist-tostring optional- Specify directory for locally persisted data.
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
This command takes a JSON file as an argument containing the keys to delete.
The following is an example of the JSON input:
1 | ["test_key_1", "test_key_2"] |
The command also accepts keys in the format output from wrangler kv key list:
1 | [{ "name": "test_key_1" }, { "name": "test_key_2" }] |
The following is an example of deleting all the keys found in the allthethingsdelete.json file.
1 | npx wrangler kv bulk delete --binding=MY_KV allthethingsdelete.json |
1 | ? Are you sure you want to delete all keys in allthethingsdelete.json from kv-namespace with id "f7b02e7fc70443149ac906dd81ec1791"? › (Y/n) |
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.
create
Create a new R2 bucket.
1 | wrangler r2 bucket create <NAME> |
NAMEstring required- The name of the new R2 bucket.
--locationstring optional- The optional location hint that determines geographic placement of the R2 bucket.
--storage-class‘Standard|InfrequentAccess’ optional- The default storage class for objects uploaded to the bucket.
--jurisdictionstring optional- The jurisdiction where the R2 bucket is created. Refer to jurisdictional restrictions.
info
Get information about an R2 bucket, including the bucket size and number of objects.
1 | wrangler r2 bucket info <NAME> |
NAMEstring required- The name of the R2 bucket to get information about.
--jurisdictionstring optional- The jurisdiction where the bucket exists, if a jurisdiction has been specified. Refer to jurisdictional restrictions.
delete
Delete an R2 bucket.
1 | wrangler r2 bucket delete <NAME> |
NAMEstring required- The name of the R2 bucket to delete.
list
List R2 bucket in the current account.
1 | wrangler r2 bucket list |
catalog enable
Enable R2 Data Catalog on an R2 bucket.
1 | wrangler r2 bucket catalog enable <NAME> [OPTIONS] |
NAMEstring required- The name of the bucket to enable R2 Data Catalog for.
catalog disable
Disable R2 Data Catalog on an R2 bucket.
1 | wrangler r2 bucket catalog disable <NAME> [OPTIONS] |
NAMEstring required- The name of the bucket to disable R2 Data Catalog for.
catalog get
Get the status of R2 Data Catalog for an R2 bucket, including catalog URI and warehouse name.
1 | wrangler r2 bucket catalog get <NAME> [OPTIONS] |
NAMEstring required- The name of the R2 bucket whose data catalog status to retrieve.
cors set
Set the CORS configuration for an R2 bucket from a JSON file.
1 | wrangler r2 bucket cors set <NAME> [OPTIONS] |
NAMEstring required- The name of the R2 bucket to set the CORS configuration for.
--filestring required- Path to the JSON file containing CORS configuration (file must be in format of request body of put bucket CORS policy API).
--jurisdictionstring optional- The jurisdiction where the bucket exists, if a jurisdiction has been specified. Refer to jurisdictional restrictions.
--forceboolean optional- Skip confirmation when setting CORS configuration.
cors delete
Clear the CORS configuration for an R2 bucket.
1 | wrangler r2 bucket cors delete <NAME> [OPTIONS] |
NAMEstring required- The name of the R2 bucket to delete the CORS configuration for.
--jurisdictionstring optional- The jurisdiction where the bucket exists, if a jurisdiction has been specified. Refer to jurisdictional restrictions.
--forceboolean optional- Skip confirmation when clearing the CORS configuration.
cors list
List the CORS configuration rules for an R2 bucket.
1 | wrangler r2 bucket cors list <NAME> [OPTIONS] |
NAMEstring required- The name of the R2 bucket to list the CORS rules for.
--jurisdictionstring optional- The jurisdiction where the bucket exists, if a jurisdiction has been specified. Refer to jurisdictional restrictions.
dev-url enable
Enable public access via the r2.dev URL for an R2 bucket.
1 | wrangler r2 bucket dev-url enable <NAME> [OPTIONS] |
NAMEstring required- The name of the R2 bucket to enable public access via its r2.dev URL.
--jurisdictionstring optional- The jurisdiction where the bucket exists, if a jurisdiction has been specified. Refer to jurisdictional restrictions.
--forceboolean optional- Skip confirmation when enabling public access via r2.dev URL.
dev-url disable
Disable public access via the r2.dev URL for an R2 bucket.
1 | wrangler r2 bucket dev-url disable <NAME> [OPTIONS] |
NAMEstring required- The name of the R2 bucket to disable public access via its r2.dev URL.
--jurisdictionstring optional- The jurisdiction where the bucket exists, if a jurisdiction has been specified. Refer to jurisdictional restrictions.
--forceboolean optional- Skip confirmation when disabling public access via r2.dev URL.
dev-url get
Get the r2.dev URL and status for an R2 bucket.
1 | wrangler r2 bucket dev-url get <NAME> [OPTIONS] |
NAMEstring required- The name of the R2 bucket whose r2.dev URL status to retrieve.
--jurisdictionstring optional- The jurisdiction where the bucket exists, if a jurisdiction has been specified. Refer to jurisdictional restrictions.
domain add
Connect a custom domain to an R2 bucket.
1 | wrangler r2 bucket domain add <NAME> [OPTIONS] |
NAMEstring required- The name of the R2 bucket to connect a custom domain to.
--domainstring required- The custom domain to connect to the R2 bucket.
--zone-idstring required- The zone ID associated with the custom domain.
--min-tls‘1.0’|‘1.1’|‘1.2’|‘1.3’ optional- Set the minimum TLS version for the custom domain (defaults to 1.0 if not set).
--jurisdictionstring optional- The jurisdiction where the bucket exists, if a jurisdiction has been specified. Refer to jurisdictional restrictions.
--forceboolean optional- Skip confirmation when adding the custom domain.
domain remove
Remove a custom domain from an R2 bucket.
1 | wrangler r2 bucket domain remove <NAME> [OPTIONS] |
NAMEstring required- The name of the R2 bucket to remove the custom domain from.
--domainstring required- The custom domain to remove from the R2 bucket.
--jurisdictionstring optional- The jurisdiction where the bucket exists, if a jurisdiction has been specified. Refer to jurisdictional restrictions.
--forceboolean optional- Skip confirmation when removing the custom domain.
domain update
Update settings for a custom domain connected to an R2 bucket.
1 | wrangler r2 bucket domain update <NAME> [OPTIONS] |
NAMEstring required- The name of the R2 bucket associated with the custom domain to update.
--domainstring required- The custom domain whose settings will be updated.
--min-tls‘1.0’|‘1.1’|‘1.2’|‘1.3’ optional- Update the minimum TLS version for the custom domain.
--jurisdictionstring optional- The jurisdiction where the bucket exists, if a jurisdiction has been specified. Refer to jurisdictional restrictions.
domain get
Get custom domain connected to an R2 bucket.
1 | wrangler r2 bucket domain get <NAME> [OPTIONS] |
NAMEstring required- The name of the R2 bucket whose custom domain to retrieve.
--domainstring required- The custom domain to get information for.
--jurisdictionstring optional- The jurisdiction where the bucket exists, if a jurisdiction has been specified. Refer to jurisdictional restrictions.
domain list
List custom domains for an R2 bucket.
1 | wrangler r2 bucket domain list <NAME> [OPTIONS] |
NAMEstring required- The name of the R2 bucket whose connected custom domains will be listed.
--jurisdictionstring optional- The jurisdiction where the bucket exists, if a jurisdiction has been specified. Refer to jurisdictional restrictions.
lifecycle add
Add an object lifecycle rule to an R2 bucket.
1 | wrangler r2 bucket lifecycle add <NAME> [OPTIONS] |
NAMEstring required- The name of the R2 bucket to add a lifecycle rule to.
--namestring optional- A unique name for the lifecycle rule, used to identify and manage it. For example:
delete-logs-180-days.
- A unique name for the lifecycle rule, used to identify and manage it. For example:
--prefixstring optional- Prefix condition for the lifecycle rule (leave empty for all prefixes).
--expire-daysnumber optional- Sets the lifecycle rule action to expire objects after this number of days. Note you can provide only one of
--expire-daysor--expire-date.
- Sets the lifecycle rule action to expire objects after this number of days. Note you can provide only one of
--expire-datestring optional- Sets the lifecycle rule action to expire objects after this date (YYYY-MM-DD). Note you can provide only one of
--expire-daysor--expire-date.
- Sets the lifecycle rule action to expire objects after this date (YYYY-MM-DD). Note you can provide only one of
--ia-transition-daysnumber optional- Sets the lifecycle rule action to transition objects to Infrequent Access storage after this number of days. Note you can provide only one of
--ia-transition-daysor--ia-transition-date.
- Sets the lifecycle rule action to transition objects to Infrequent Access storage after this number of days. Note you can provide only one of
--ia-transition-datestring optional- Sets the lifecycle rule action to transition objects to Infrequent Access storage after this date (YYYY-MM-DD). Note you can provide only one of
--ia-transition-daysor--ia-transition-date.
- Sets the lifecycle rule action to transition objects to Infrequent Access storage after this date (YYYY-MM-DD). Note you can provide only one of
--abort-multipart-daysnumber optional- Sets the lifecycle rule action to abort incomplete multipart uploads after this number of days.
--jurisdictionstring optional- The jurisdiction where the bucket exists, if a jurisdiction has been specified. Refer to jurisdictional restrictions.
--forceboolean optional- Skip confirmation when adding the lifecycle rule.
lifecycle remove
Remove an object lifecycle rule from an R2 bucket.
1 | wrangler r2 bucket lifecycle remove <NAME> [OPTIONS] |
NAMEstring required- The name of the R2 bucket to remove a lifecycle rule from.
--namestring required- The unique name of the lifecycle rule to remove.
--jurisdictionstring optional- The jurisdiction where the bucket exists, if a jurisdiction has been specified. Refer to jurisdictional restrictions.
lifecycle list
List object lifecycle rules for an R2 bucket.
1 | wrangler r2 bucket lifecycle list <NAME> [OPTIONS] |
NAMEstring required- The name of the R2 bucket to list lifecycle rules for.
--jurisdictionstring optional- The jurisdiction where the bucket exists, if a jurisdiction has been specified. Refer to jurisdictional restrictions.
lifecycle set
Set the object lifecycle configuration for an R2 bucket from a JSON file.
1 | wrangler r2 bucket lifecycle set <NAME> [OPTIONS] |
NAMEstring required- The name of the R2 bucket to set lifecycle configuration for.
--filestring required- Path to the JSON file containing lifecycle configuration (file must be in format of request body of put object lifecycle configuration API).
--jurisdictionstring optional- The jurisdiction where the bucket exists, if a jurisdiction has been specified. Refer to jurisdictional restrictions.
--forceboolean optional- Skip confirmation when setting object lifecycle configuration.
lock add
Add a bucket lock rule to an R2 bucket.
1 | wrangler r2 bucket lock add <NAME> [OPTIONS] |
NAMEstring required- The name of the R2 bucket to add a bucket lock rule to.
--namestring optional- A unique name for the bucket lock rule, used to identify and manage it. For example:
retain-logs-180-days.
- A unique name for the bucket lock rule, used to identify and manage it. For example:
--prefixstring optional- Prefix condition for the bucket lock rule (leave empty for all prefixes).
--retention-daysnumber optional- Sets the number of days to retain objects for. Note you can provide only one of
--retention-days,--retention-date, or--retention-indefinite.
- Sets the number of days to retain objects for. Note you can provide only one of
--retention-datestring optional- Sets the number of days to retain objects for. Note you can provide only one of
--retention-days,--retention-date, or--retention-indefinite.
- Sets the number of days to retain objects for. Note you can provide only one of
--retention-indefinitestring optional- Sets the retention period to indefinite — meaning the lock will remain in place until explicitly removed. Note you can provide only one of
--retention-days,--retention-date, or--retention-indefinite.
- Sets the retention period to indefinite — meaning the lock will remain in place until explicitly removed. Note you can provide only one of
--jurisdictionstring optional- The jurisdiction where the bucket exists, if a jurisdiction has been specified. Refer to jurisdictional restrictions.
--forceboolean optional- Skip confirmation when adding the bucket lock rule.
lock remove
Remove a bucket lock rule from an R2 bucket.
1 | wrangler r2 bucket lock remove <NAME> [OPTIONS] |
NAMEstring required- The name of the R2 bucket to remove a bucket lock rule from.
--namestring required- The unique name of the bucket lock rule to remove.
--jurisdictionstring optional- The jurisdiction where the bucket exists, if a jurisdiction has been specified. Refer to jurisdictional restrictions.
lock list
List bucket lock rules for an R2 bucket.
1 | wrangler r2 bucket lock list <NAME> [OPTIONS] |
NAMEstring required- The name of the R2 bucket to list bucket locks rules for.
--jurisdictionstring optional- The jurisdiction where the bucket exists, if a jurisdiction has been specified. Refer to jurisdictional restrictions.
lock set
Set the bucket lock configuration for an R2 bucket from a JSON file.
1 | wrangler r2 bucket lock set <NAME> [OPTIONS] |
NAMEstring required- The name of the R2 bucket to set bucket lock configuration for.
--filestring required- Path to the JSON file containing bucket lock configuration (file must be in format of request body of put bucket lock configuration API).
--jurisdictionstring optional- The jurisdiction where the bucket exists, if a jurisdiction has been specified. Refer to jurisdictional restrictions.
--forceboolean optional- Skip confirmation when setting bucket lock configuration.
notification create
Create an event notification rule for an R2 bucket.
1 | wrangler r2 bucket notification create <NAME> [OPTIONS] |
NAMEstring required- The name of the R2 bucket to create an event notification rule for.
--event-type‘object-create’|‘object-delete’[] required- The type of event(s) that will trigger event notifications.
--queuestring required- The name of the queue that will receive event notification messages.
--prefixstring optional- The prefix that an object must match to emit event notifications (note: regular expressions are not supported).
--suffixstring optional- The suffix that an object must match to emit event notifications (note: regular expressions are not supported).
--descriptionstring optional- A description that can be used to identify the event notification rule after creation.
notification delete
Remove an event notification rule from a bucket’s event notification configuration.
1 | wrangler r2 bucket notification delete <NAME> [OPTIONS] |
NAMEstring required- The name of the R2 bucket to delete an event notification rule for.
--queuestring required- The name of the queue that corresponds to the event notification rule. If no
ruleis provided, all event notification rules associated with the queue will be deleted.
- The name of the queue that corresponds to the event notification rule. If no
--rulestring optional- The ID of the event notification rule to delete.
notification list
List the event notification rules for a bucket.
1 | wrangler r2 bucket notification list <NAME> |
NAMEstring required- The name of the R2 bucket to get event notification rules for.
sippy enable
Enable Sippy incremental migration for a bucket.
1 | wrangler r2 bucket sippy enable <NAME> [OPTIONS] |
NAMEstring required- The name of the R2 bucket to enable Sippy.
--provider‘AWS’|‘GCS’ required- The provider of your source object storage bucket.
--bucketstring required- The name of your source object storage bucket.
--r2-key-idstring required- Your R2 Access Key ID. Requires read and write access.
--r2-secret-access-keystring required- Your R2 Secret Access Key. Requires read and write access.
--jurisdictionstring optional- The jurisdiction where the bucket exists, if a jurisdiction has been specified. Refer to jurisdictional restrictions.
- AWS S3 provider-specific options:
--key-idstring optional- Your AWS Access Key ID. Requires read and list access.
--secret-access-keystring optional- Your AWS Secret Access Key. Requires read and list access.
--regionstring optional- The AWS region where your S3 bucket is located. For example:
us-west-2.
- The AWS region where your S3 bucket is located. For example:
- Google Cloud Storage provider-specific options:
--service-account-key-filestring optional- The path to your Google Cloud service account key JSON file. This will read the service account key file and populate
client_emailandprivate_keyoptions. Requires read and list access.
- The path to your Google Cloud service account key JSON file. This will read the service account key file and populate
--client-emailstring optional- The client email for your Google Cloud service account key. Requires read and list access.
--private-keystring optional- The private key for your Google Cloud service account key. Requires read and list access.
- Note that you must provide either
service-account-key-fileorclient_emailandprivate_keyfor this command to run successfully.
sippy disable
Disable Sippy incremental migration for a bucket.
1 | wrangler r2 bucket sippy disable <NAME> |
NAMEstring required- The name of the R2 bucket to disable Sippy.
sippy get
Get the status of Sippy incremental migration for a bucket.
1 | wrangler r2 bucket sippy get <NAME> |
NAMEstring required- The name of the R2 bucket to get the status of Sippy.
r2 object
Interact with R2 objects.
Note
The r2 object commands allow you to manage application data in the Cloudflare network to be accessed from Workers using the R2 API.
get
Fetch an object from an R2 bucket.
1 | wrangler r2 object get <OBJECT_PATH> [OPTIONS] |
OBJECT_PATHstring required- The source object path in the form of
{bucket}/{key}.
- The source object path in the form of
--localboolean (default: true) optional- Interact with locally persisted data.
--remoteboolean (default: false) optional- Interact with remote storage.
--persist-tostring optional- Specify directory for locally persisted data.
put
Create an object in an R2 bucket.
1 | wrangler r2 object put <OBJECT_PATH> [OPTIONS] |
OBJECT_PATHstring required- The destination object path in the form of
{bucket}/{key}.
- The destination object path in the form of
--filestring optional- The path of the file to upload. Note you must provide either
--fileor--pipe.
- The path of the file to upload. Note you must provide either
--pipeboolean optional- Enables the file to be piped in, rather than specified with the
--fileoption. Note you must provide either--fileor--pipe.
- Enables the file to be piped in, rather than specified with the
--content-typestring optional- A standard MIME type describing the format of the object data.
--content-dispositionstring optional- Specifies presentational information for the object.
--content-encodingstring optional- Specifies what content encodings have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the
Content-Typeheader field.
- Specifies what content encodings have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the
--content-languagestring optional- The language the content is in.
--cache-controlstring optional- Specifies caching behavior along the request/reply chain.
--expiresstring optional- The date and time at which the object is no longer cacheable.
--localboolean (default: true) optional- Interact with locally persisted data.
--remoteboolean (default: false) optional- Interact with remote storage.
--persist-tostring optional- Specify directory for locally persisted data.
delete
Delete an object in an R2 bucket.
1 | wrangler r2 object delete <OBJECT_PATH> [OPTIONS] |
OBJECT_PATHstring required- The destination object path in the form of
{bucket}/{key}.
- The destination object path in the form of
--localboolean (default: true) optional- Interact with locally persisted data.
--remoteboolean (default: false) optional- Interact with remote storage.
--persist-tostring optional- Specify directory for locally persisted data.
Note
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
secret
Manage the secret variables for a Worker.
This action creates a new version of the Worker and deploys it immediately. To only create a new version of the Worker, use the wrangler versions secret commands.
put
Create or replace a secret for a Worker.
1 | wrangler secret put <KEY> [OPTIONS] |
KEYstring required- The variable name for this secret to be accessed in the Worker.
--namestring optional- Perform on a specific Worker rather than inheriting from a Wrangler configuration file.
--envstring optional- Perform on a specific environment.
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
When running this command, you will be prompted to input the secret’s value:
1 | npx wrangler secret put FOO |
1 | ? Enter a secret value: › *** |
The put command can also receive piped input. For example:
1 | echo "-----BEGIN PRIVATE KEY-----\nM...==\n-----END PRIVATE KEY-----\n" | wrangler secret put PRIVATE_KEY |
delete
Delete a secret for a Worker.
1 | wrangler secret delete <KEY> [OPTIONS] |
KEYstring required- The variable name for this secret to be accessed in the Worker.
--namestring optional- Perform on a specific Worker rather than inheriting from the Wrangler configuration file.
--envstring optional- Perform on a specific environment.
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
list
List the names of all the secrets for a Worker.
1 | wrangler secret list [OPTIONS] |
--namestring optional- Perform on a specific Worker rather than inheriting from the Wrangler configuration file.
--envstring optional- Perform on a specific environment
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
The following is an example of listing the secrets for the current Worker.
1 | npx wrangler secret list |
1 | [ |
secret bulk
Upload multiple secrets for a Worker at once.
1 | wrangler secret bulk [<FILENAME>] [OPTIONS] |
-
FILENAMEstring optional- A file containing either JSON or the .env format
- The JSON file containing key-value pairs to upload as secrets, in the form
{"SECRET_NAME": "secret value", ...}. - The
.envfile containing key-value pairs to upload as secrets, in the formSECRET_NAME=secret value. - If omitted, Wrangler expects to receive input from
stdinrather than a file.
-
--namestring optional- Perform on a specific Worker rather than inheriting from the Wrangler configuration file.
-
--envstring optional- Perform on a specific environment.
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
The following is an example of uploading secrets from a JSON file redirected to stdin. When complete, the output summary will show the number of secrets uploaded and the number of secrets that failed to upload.
1 | { |
1 | npx wrangler secret bulk < secrets.json |
1 | 🌀 Creating the secrets for the Worker "script-name" |
secrets-store secret
With the release of Secrets Store in open beta, you can use the following commands to manage your account secrets.
--remote option
In order to interact with Secrets Store in production, you should append --remote to your command. Without it, your command will default to local development mode.
create
Create a secret within a store.
1 | wrangler secrets-store secret create <STORE_ID> [OPTIONS] |
-
STORE_IDstring required- The secret store public ID. You can find it and copy from the Secrets Store tab on the dashboard.
-
--namestring required- A descriptive name for the account-level secret. Cannot contain spaces.
-
--valuestring test only-
Value of the secret.
Only use for testing
This will leave the secret value in plain-text in terminal history. For real secret values, use the automatic prompt instead. Find an example below.
-
-
--scopesstring required- Which services will have access to the account-level secret. Currently, only
workersis available.
- Which services will have access to the account-level secret. Currently, only
-
--commentstring optional- Additional information about the account-level secret.
-
--remoteboolean (default: false) optional- Execute the command against the remote Secrets Store. To interact with account-level secrets in production, make sure to append
--remoteto your commands.
- Execute the command against the remote Secrets Store. To interact with account-level secrets in production, make sure to append
The following is an example of using the create command to create an account-level secret.
1 | npx wrangler secrets-store secret create 8f7a1cdced6342c18d223ece462fd88d --name ServiceA_key-1 --scopes workers --remote |
1 | ✓ Enter a secret value: › *** |
update
Update a secret within a store.
1 | wrangler secrets-store secret update <STORE_ID> [OPTIONS] |
-
STORE_IDstring required- The ID of the secrets store that contains the secret you are updating.
-
--secret-idstring required- The ID of the secret to update.
-
--valuestring test only-
Updated value of the secret.
Only use for testing
This will leave the secret value in plain-text in terminal history. For real secret values, use the automatic prompt instead.
-
-
--scopesstring required- Which services will have access to the account-level secret. Currently, only
workersis available.
- Which services will have access to the account-level secret. Currently, only
-
--commentstring optional- Updated comment for the account-level secret.
-
--remoteboolean (default: false) optional- Execute the command against the remote Secrets Store. To interact with account-level secrets in production, make sure to append
--remoteto your commands.
- Execute the command against the remote Secrets Store. To interact with account-level secrets in production, make sure to append
duplicate
Duplicate a secret within a store. Use this command to create a new secret that holds the same secret value as an existing secret.
1 | wrangler secrets-store secret duplicate <STORE_ID> [OPTIONS] |
STORE_IDstring required- The ID of the secrets store that contains the secret you are duplicating.
--secret-idstring required- The ID of the secret you are duplicating.
--namestring required- A name for the new secret. Cannot contain spaces.
--scopesstring required- Which services will have access to the new account-level secret. Currently, only
workersis available.
- Which services will have access to the new account-level secret. Currently, only
--commentstring optional- Additional information about the new account-level secret.
--remoteboolean (default: false) optional- Execute the command against the remote Secrets Store. To interact with account-level secrets in production, make sure to append
--remoteto your commands.
- Execute the command against the remote Secrets Store. To interact with account-level secrets in production, make sure to append
get
Get information on a secret within a store.
1 | wrangler secrets-store secret get <STORE_ID> [OPTIONS] |
STORE_IDstring required- The ID of the secrets store that contains the secret you want to get.
--secret-idstring required- The ID of the secret you want to get.
--remoteboolean (default: false) optional- Execute the command against the remote Secrets Store. To interact with account-level secrets in production, make sure to append
--remoteto your commands.
- Execute the command against the remote Secrets Store. To interact with account-level secrets in production, make sure to append
The following is an example with the expected output:
1 | npx wrangler secrets-store secret get 8f7a1cdced6342c18d223ece462fd88d --secret-id 13bc7498c6374a4e9d13be091c3c65f1 --remote |
1 | 🔐 Getting secret... (ID: 13bc7498c6374a4e9d13be091c3c65f1) |
delete
Delete a secret within a store.
Warning
Before deleting a secret, make sure it is not deployed in any Workers application.
1 | wrangler secrets-store secret delete <STORE_ID> [OPTIONS] |
STORE_IDstring required- The ID of the secrets store that contains the secret you are deleting.
--secret-idstring required- The ID of the secret you are deleting.
--remoteboolean (default: false) optional- Execute the command against the remote Secrets Store. To interact with account-level secrets in production, make sure to append
--remoteto your commands.
- Execute the command against the remote Secrets Store. To interact with account-level secrets in production, make sure to append
list
List secrets within a store.
1 | wrangler secrets-store secret list <STORE_ID> |
STORE_IDstring required- The secret store public ID. You can find it and copy from the Secrets Store tab on the dashboard.
secrets-store store
Use the following commands to manage your store.
Store limitation
Secrets Store is in open beta. Currently, you can only have one store per Cloudflare account.
create
Create a store within Secrets Store.
1 | wrangler secrets-store store create <name> |
namestring required- A descriptive name for the account-level secret. Cannot contain spaces.
--remoteboolean (default: false) required- Execute the command against the remote Secrets Store.
The following is an example of using the create command to create a store.
1 | npx wrangler secrets-store store create default --remote |
1 | 🔐 Creating store... (Name: default) |
delete
Delete a store within Secrets Store.
1 | wrangler secrets-store store delete <STORE_ID> |
STORE_IDstring required- The secret store public ID. You can find it and copy from the Secrets Store tab on the dashboard.
--remoteboolean (default: false) required- Execute the command against the remote Secrets Store.
The following is an example of using the delete command to delete a store.
1 | npx wrangler secrets-store store delete d2dafaeac9434de2b6d08b292ce08211 --remote |
1 | 🔐 Deleting store... (Name: d2dafaeac9434de2b6d08b292ce08211) |
list
List the stores within an account.
1 | wrangler secrets-store store list |
--remoteboolean (default: false) required- Execute the command against the remote Secrets Store.
The following is an example of using the list command to list stores.
1 | npx wrangler secrets-store store list --remote |
1 | 🔐 Listing stores... |
workflows
Note
The wrangler workflows command requires Wrangler version 3.83.0 or greater. Use npx wrangler@latest to always use the latest Wrangler version when invoking commands.
Manage and configure Workflows.
list
Lists the registered Workflows for this account.
1 | wrangler workflows list |
--pagenumber optional- Show a specific page from the listing. You can configure page size using “per-page”.
--per-pagenumber optional- Configure the maximum number of Workflows to show per page.
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
instances
Manage and interact with specific instances of a Workflow.
instances list
List Workflow instances.
1 | wrangler workflows instances list <WORKFLOW_NAME> [OPTIONS] |
WORKFLOW_NAMEstring required- The name of a registered Workflow.
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
instances describe
Describe a specific instance of a Workflow, including its current status, any persisted state, and per-step outputs.
1 | wrangler workflows instances describe <WORKFLOW_NAME> <ID> [OPTIONS] |
WORKFLOW_NAMEstring required- The name of a registered Workflow.
IDstring required- The ID of a Workflow instance. You can optionally provide
latestto refer to the most recently created instance of a Workflow.
- The ID of a Workflow instance. You can optionally provide
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
1 | # Passing `latest` instead of an explicit ID will describe the most recently queued instance |
1 | Workflow Name: my-workflow |
instances terminate
Terminate (permanently stop) a Workflow instance.
1 | wrangler workflows instances terminate <WORKFLOW_NAME> <ID> [OPTIONS] |
WORKFLOW_NAMEstring required- The name of a registered Workflow.
IDstring required- The ID of a Workflow instance.
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
instances pause
Pause (until resumed) a Workflow instance.
1 | wrangler workflows instances pause <WORKFLOW_NAME> <ID> [OPTIONS] |
WORKFLOW_NAMEstring required- The name of a registered Workflow.
IDstring required- The ID of a Workflow instance.
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
instances resume
Resume a paused Workflow instance.
1 | wrangler workflows instances resume <WORKFLOW_NAME> <ID> [OPTIONS] |
WORKFLOW_NAMEstring required- The name of a registered Workflow.
IDstring required- The ID of a Workflow instance.
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
describe
1 | wrangler workflows describe <WORKFLOW_NAME> [OPTIONS] |
WORKFLOW_NAMEstring required- The name of a registered Workflow.
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
delete
Delete a Workflow and all its instances.
1 | wrangler workflows delete <WORKFLOW_NAME> [OPTIONS] |
WORKFLOW_NAMEstring required- The name of a registered Workflow.
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
1 | wrangler workflows instances delete my-workflow |
trigger
Trigger (create) a Workflow instance.
1 | wrangler workflows trigger <WORKFLOW_NAME> <PARAMS> [OPTIONS] |
WORKFLOW_NAMEstring required- The name of a registered Workflow.
PARAMSstring optional- The parameters to pass to the Workflow as an event. Must be a JSON-encoded string.
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
1 | # Pass optional params to the Workflow. |
tail
Start a session to livestream logs from a deployed Worker.
1 | wrangler tail <WORKER> [OPTIONS] |
WORKERstring required- The name of your Worker or the route the Worker is running on.
--format‘json’|‘pretty’ optional- The format of the log entries.
--status‘ok’|‘error’|‘canceled’ optional- Filter by invocation status.
--headerstring optional- Filter by HTTP header.
--methodstring optional- Filter by HTTP method.
--sampling-ratenumber optional- Add a fraction of requests to log sampling rate (between
0and1).
- Add a fraction of requests to log sampling rate (between
--searchstring optional- Filter by a text match in
console.logmessages.
- Filter by a text match in
--ip(string|‘self’)\[]" optional- Filter by the IP address the request originates from. Use
"self"to show only messages from your own IP.
- Filter by the IP address the request originates from. Use
--version-idstring optional- Filter by Worker version.
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
After starting wrangler tail, you will receive a live feed of console and exception logs for each request your Worker receives.
If your Worker has a high volume of traffic, the tail might enter sampling mode. This will cause some of your messages to be dropped and a warning to appear in your tail logs. To prevent messages from being dropped, add the options listed above to filter the volume of tail messages.
Note
It may take up to 1 minute (60 seconds) for a tail to exit sampling mode after adding an option to filter tail messages.
If sampling persists after using options to filter messages, consider using instant logs.
pages
Configure Cloudflare Pages.
dev
Develop your full-stack Pages application locally.
1 | wrangler pages dev [<DIRECTORY>] [OPTIONS] |
-
DIRECTORYstring optional- The directory of static assets to serve.
-
--localboolean optional (default: true)- Run on your local machine.
-
--ipstring optional- IP address to listen on, defaults to
localhost.
- IP address to listen on, defaults to
-
--portnumber optional (default: 8788)- The port to listen on (serve from).
-
--config,-cstring[] optional- Path(s) to Wrangler configuration file. If not provided, Wrangler will use the nearest config file based on your current working directory.
- You can provide additional configuration files in order to run Workers alongside your Pages project, like this:
wrangler pages dev -c ./wrangler.toml -c ../other-worker/wrangler.toml. The first argument must point to your Pages configuration file, and the subsequent configurations will be accessible via a Service binding from your Pages project.
-
--bindingstring[] optional- Bind an environment variable or secret (for example,
--binding <VARIABLE_NAME>=<VALUE>).
- Bind an environment variable or secret (for example,
-
--kvstring[] optional- Binding name of KV namespace to bind (for example,
--kv <BINDING_NAME>).
- Binding name of KV namespace to bind (for example,
-
--r2string[] optional- Binding name of R2 bucket to bind (for example,
--r2 <BINDING_NAME>).
- Binding name of R2 bucket to bind (for example,
-
--d1string[] optional- Binding name of D1 database to bind (for example,
--d1 <BINDING_NAME>).
- Binding name of D1 database to bind (for example,
-
--dostring[] optional- Binding name of Durable Object to bind (for example,
--do <BINDING_NAME>=<CLASS>).
- Binding name of Durable Object to bind (for example,
-
--live-reloadboolean optional (default: false)- Auto reload HTML pages when change is detected.
-
--compatibility-flagstring[] optional- Runtime compatibility flags to apply.
-
--compatibility-datestring optional- Runtime compatibility date to apply.
-
--show-interactive-dev-sessionboolean optional (default: true if the terminal supports interactivity)- Show the interactive dev session.
-
--https-key-pathstring optional- Path to a custom certificate key.
-
--https-cert-pathstring optional- Path to a custom certificate.
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
download config
Download your Pages project config as a Wrangler configuration file.
1 | wrangler pages download config <PROJECT_NAME> |
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
project list
List your Pages projects.
1 | wrangler pages project list |
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
project create
Create a new Cloudflare Pages project.
1 | wrangler pages project create <PROJECT_NAME> [OPTIONS] |
PROJECT_NAMEstring required- The name of your Pages project.
--production-branchstring optional- The name of the production branch of your project.
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
project delete
Delete a Cloudflare Pages project.
1 | wrangler pages project delete <PROJECT_NAME> [OPTIONS] |
PROJECT_NAMEstring required- The name of the Pages project to delete.
--yesboolean optional- Answer
"yes"to confirmation prompt.
- Answer
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
deployment list
List deployments in your Cloudflare Pages project.
1 | wrangler pages deployment list [--project-name <PROJECT_NAME>] |
--project-namestring optional- The name of the project you would like to list deployments for.
--environment‘production’|‘preview’ optional- Environment type to list deployments for.
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
deployment tail
Start a session to livestream logs from your deployed Pages Functions.
1 | wrangler pages deployment tail [<DEPLOYMENT>] [OPTIONS] |
DEPLOYMENTstring optional- ID or URL of the deployment to tail. Specify by environment if deployment ID is unknown.
--project-namestring optional- The name of the project you would like to tail.
--environment‘production’|‘preview’ optional- When not providing a specific deployment ID, specifying environment will grab the latest production or preview deployment.
--format‘json’|‘pretty’ optional- The format of the log entries.
--status‘ok’|‘error’|‘canceled’ optional- Filter by invocation status.
--headerstring optional- Filter by HTTP header.
--methodstring optional- Filter by HTTP method.
--sampling-ratenumber optional- Add a percentage of requests to log sampling rate.
--searchstring optional- Filter by a text match in
console.logmessages.
- Filter by a text match in
--ip(string|‘self’)\[] optional- Filter by the IP address the request originates from. Use
"self"to show only messages from your own IP.
- Filter by the IP address the request originates from. Use
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
Note
Filtering with --ip self will allow tailing your deployed Functions beyond the normal request per second limits.
After starting wrangler pages deployment tail, you will receive a live stream of console and exception logs for each request your Functions receive.
deploy
Deploy a directory of static assets as a Pages deployment.
1 | wrangler pages deploy <BUILD_OUTPUT_DIRECTORY> [OPTIONS] |
BUILD_OUTPUT_DIRECTORYstring optional- The directory of static files to upload. As of Wrangler 3.45.0, this is only required when your Pages project does not have a Wrangler file. Refer to the Pages Functions configuration guide for more information.
--project-namestring optional- The name of the project you want to deploy to.
--branchstring optional- The name of the branch you want to deploy to.
--commit-hashstring optional- The SHA to attach to this deployment.
--commit-messagestring optional- The commit message to attach to this deployment.
--commit-dirtyboolean optional- Whether or not the workspace should be considered dirty for this deployment.
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
Note
Your site is deployed to <PROJECT_NAME>.pages.dev. If you do not provide the --project-name argument, you will be prompted to enter a project name in your terminal after you run the command.
secret put
Create or update a secret for a Pages project.
1 | wrangler pages secret put <KEY> [OPTIONS] |
KEYstring required- The variable name for this secret to be accessed in the Pages project.
--project-namestring optional- The name of your Pages project.
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
secret delete
Delete a secret from a Pages project.
1 | wrangler pages secret delete <KEY> [OPTIONS] |
KEYstring required- The variable name for this secret to be accessed in the Pages project.
--project-namestring optional- The name of your Pages project.
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
secret list
List the names of all the secrets for a Pages project.
1 | wrangler pages secret list [OPTIONS] |
--project-namestring optional- The name of your Pages project.
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
secret bulk
Upload multiple secrets for a Pages project at once.
1 | wrangler pages secret bulk [<FILENAME>] [OPTIONS] |
-
FILENAMEstring optional- A file containing either JSON or the .env format
- The JSON file containing key-value pairs to upload as secrets, in the form
{"SECRET_NAME": "secret value", ...}. - The
.envfile containing key-value pairs to upload as secrets, in the formSECRET_NAME=secret value. - If omitted, Wrangler expects to receive input from
stdinrather than a file.
-
--project-namestring optional- The name of your Pages project.
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
functions build
Compile a folder of Pages Functions into a single Worker.
1 | wrangler pages functions build [<DIRECTORY>] [OPTIONS] |
DIRECTORYstring optional (default: `functions`)- The directory of Pages Functions.
--outdirstring optional- Output directory for the bundled Worker.
--fallback-servicestring optional (default: `ASSETS`)- The service to fallback to at the end of the
nextchain. Setting to''will fallback to the globalfetch.
- The service to fallback to at the end of the
--compatibility-datestring optional- Date to use for compatibility checks.
--compatibility-flagsstring[] optional- Flags to use for compatibility checks.
--metafilestring optional- Specify a file to write the build metadata from esbuild to. If flag is used without a path string, this defaults to
bundle-meta.jsoninside the directory specified by--outdir. This can be useful for understanding the bundle size.
- Specify a file to write the build metadata from esbuild to. If flag is used without a path string, this defaults to
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
pipelines
Manage your Pipelines.
Note
Pipelines is currently in open beta. Report Pipelines bugs in GitHub.
create
Create a new pipeline
1 | wrangler pipelines create <name> --r2 <r2-bucket-name> [OPTIONS] |
namestring required- The name of the pipeline to create
--sourcearray optional- List of allowed sources. Options:
httporworker
- List of allowed sources. Options:
--require-http-authboolean optional- Require Cloudflare API token to authenticate with the HTTPS endpoint. Defaults to
false.
- Require Cloudflare API token to authenticate with the HTTPS endpoint. Defaults to
--cors-originsarray optional- CORS Origin allowlist for HTTP endpoint. Allows
*. Defaults to an empty array.
- CORS Origin allowlist for HTTP endpoint. Allows
--batch-max-mbnumber optional- The maximum size of a batch in megabytes before data is written. Defaults to
100. Must be between1and100.
- The maximum size of a batch in megabytes before data is written. Defaults to
--batch-max-rowsnumber optional- The maximum number of rows in a batch before data is written. Defaults to
10000000. Must be between1and10000000.
- The maximum number of rows in a batch before data is written. Defaults to
--batch-max-secondsnumber optional- The maximum duration of a batch before data is written in seconds. Defaults to
300. Must be between1and300.
- The maximum duration of a batch before data is written in seconds. Defaults to
--r2-bucketstring required- The name of the R2 bucket used as the destination to store the data.
--r2-bucket-access-key-idstring optional- Access key ID used to authenticate with R2. Leave empty for oauth confirmation.
--r2-bucket-secret-access-keystring optional- Secret access key ID used to authenticate with R2. Leave empty for oauth confirmation.
--r2-prefixstring optional- Prefix for storing files in the destination bucket.
--compressionstring optional- Type of compression to apply to output files. Choices:
none,gzip,deflate
- Type of compression to apply to output files. Choices:
--shard-countnumber optional- Number of pipeline shards. More shards handle higher request volume; fewer shards produce larger output files. Defaults to
2. Must be between1and15.
- Number of pipeline shards. More shards handle higher request volume; fewer shards produce larger output files. Defaults to
update
Update an existing pipeline
1 | wrangler pipelines update <name> [OPTIONS] |
namestring required- The name of the pipeline to create
--sourcearray optional- List of allowed sources. Options:
httporworker
- List of allowed sources. Options:
--require-http-authboolean optional- Require Cloudflare API token to authenticate with the HTTPS endpoint. Defaults to
false.
- Require Cloudflare API token to authenticate with the HTTPS endpoint. Defaults to
--cors-originsarray optional- CORS Origin allowlist for HTTP endpoint. Allows
*. Defaults to an empty array.
- CORS Origin allowlist for HTTP endpoint. Allows
--batch-max-mbnumber optional- The maximum size of a batch in megabytes before data is written. Defaults to
100. Must be between1and100.
- The maximum size of a batch in megabytes before data is written. Defaults to
--batch-max-rowsnumber optional- The maximum number of rows in a batch before data is written. Defaults to
10000000. Must be between1and10000000.
- The maximum number of rows in a batch before data is written. Defaults to
--batch-max-secondsnumber optional- The maximum duration of a batch before data is written in seconds. Defaults to
300. Must be between1and300.
- The maximum duration of a batch before data is written in seconds. Defaults to
--r2-bucketstring required- The name of the R2 bucket used as the destination to store the data.
--r2-bucket-access-key-idstring optional- Access key ID used to authenticate with R2. Leave empty for oauth confirmation.
--r2-bucket-secret-access-keystring optional- Secret access key ID used to authenticate with R2. Leave empty for oauth confirmation.
--r2-prefixstring optional- Prefix for storing files in the destination bucket.
--compressionstring optional- Type of compression to apply to output files. Choices:
none,gzip,deflate
- Type of compression to apply to output files. Choices:
--shard-countnumber optional- Number of pipeline shards. More shards handle higher request volume; fewer shards produce larger output files. Defaults to
2. Must be between1and15.
- Number of pipeline shards. More shards handle higher request volume; fewer shards produce larger output files. Defaults to
get
Get the configuration for an existing pipeline.
1 | wrangler pipelines get <name> [OPTIONS] |
namestring required- The name of the pipeline to inspect
delete
Deletes an existing pipeline
1 | wrangler pipelines delete <name> [OPTIONS] |
namestring required- The name of the pipeline to delete
list
Lists all pipelines in your account.
1 | wrangler pipelines list [OPTIONS] |
queues
Manage your Workers Queues configurations.
create
Create a new queue.
1 | wrangler queues create <name> [OPTIONS] |
namestring required- The name of the queue to create.
--delivery-delay-secsnumber optional- How long a published message should be delayed for, in seconds. Must be a positive integer.
--message-retention-period-secsnumber optional- How long a published message is retained in the Queue. Must be a positive integer between 60 and 1209600 (14 days). Defaults to 345600 (4 days).
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
update
Update an existing queue.
1 | wrangler queues update <name> [OPTIONS] |
namestring required- The name of the queue to update.
--delivery-delay-secsnumber optional- How long a published message should be delayed for, in seconds. Must be a positive integer.
--message-retention-period-secsnumber optional- How long a published message is retained on the Queue. Must be a positive integer between 60 and 1209600 (14 days). Defaults to 345600 (4 days).
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
delete
Delete an existing queue.
1 | wrangler queues delete <name> [OPTIONS] |
namestring required- The name of the queue to delete.
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
list
List all queues in the current account.
1 | wrangler queues list [OPTIONS] |
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
info
Get information on individual queues.
1 | wrangler queues info <name> |
namestring required- The name of the queue to inspect.
consumer
Manage queue consumer configurations.
consumer add <script-name>
Add a Worker script as a queue consumer.
1 | wrangler queues consumer add <queue-name> <script-name> [OPTIONS] |
queue-namestring required- The name of the queue to add the consumer to.
script-namestring required- The name of the Workers script to add as a consumer of the named queue.
--batch-sizenumber optional- Maximum number of messages per batch. Must be a positive integer.
--batch-timeoutnumber optional- Maximum number of seconds to wait to fill a batch with messages. Must be a positive integer.
--message-retriesnumber optional- Maximum number of retries for each message. Must be a positive integer.
--max-concurrencynumber optional- The maximum number of concurrent consumer invocations that will be scaled up to handle incoming message volume. Must be a positive integer.
--retry-delay-secsnumber optional- How long a retried message should be delayed for, in seconds. Must be a positive integer.
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
consumer remove
Remove a consumer from a queue.
1 | wrangler queues consumer remove <queue-name> <script-name> |
queue-namestring required- The name of the queue to remove the consumer from.
script-namestring required- The name of the Workers script to remove as the consumer.
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
purge
Permanently delete all messages in a queue.
1 | wrangler queues purge <queue-name> |
queue-namestring required- The name of the queue from which messages should be deleted.
pause-delivery
Pause message delivery from a Queue to consumers (including push consumers, and HTTP pull consumers)
1 | wrangler queues pause-delivery <queue-name> |
queue-namestring required- The name of the queue which delivery should be paused.
resume-delivery
Resume delivery from a Queue to consumers (including push consumers, and HTTP pull consumers)
1 | wrangler queues resume-delivery <queue-name> |
queue-namestring required- The name of the queue from which delivery should be resumed.
login
Authorize Wrangler with your Cloudflare account using OAuth. Wrangler will attempt to automatically open your web browser to login with your Cloudflare account.
If you prefer to use API tokens for authentication, such as in headless or continuous integration environments, refer to Running Wrangler in CI/CD.
1 | wrangler login [OPTIONS] |
--scopes-liststring optional- List all the available OAuth scopes with descriptions.
--scopesstring optional- Allows to choose your set of OAuth scopes. The set of scopes must be entered in a whitespace-separated list, for example,
npx wrangler login --scopes account:read user:read.
- Allows to choose your set of OAuth scopes. The set of scopes must be entered in a whitespace-separated list, for example,
--callback-hoststring optional- Defaults to
localhost. Sets the IP or hostname where Wrangler should listen for the OAuth callback.
- Defaults to
--callback-portstring optional- Defaults to
8976. Sets the port where Wrangler should listen for the OAuth callback.
- Defaults to
Note
wrangler login uses all the available scopes by default if no flags are provided.
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
If Wrangler fails to open a browser, you can copy and paste the URL generated by wrangler login in your terminal into a browser and log in.
Use wrangler login on a remote machine
If you are using Wrangler from a remote machine, but run the login flow from your local browser, you will receive the following error message after logging in:This site can't be reached.
To finish the login flow, run wrangler login and go through the login flow in the browser:
1 | npx wrangler login |
1 | ⛅️ wrangler 2.1.6 |
The browser login flow will redirect you to a localhost URL on your machine.
Leave the login flow active. Open a second terminal session. In that second terminal session, use curl or an equivalent request library on the remote machine to fetch this localhost URL. Copy and paste the localhost URL that was generated during the wrangler login flow and run:
1 | curl <LOCALHOST_URL> |
logout
Remove Wrangler’s authorization for accessing your account. This command will invalidate your current OAuth token.
1 | wrangler logout |
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
If you are using CLOUDFLARE_API_TOKEN instead of OAuth, and you can logout by deleting your API token in the Cloudflare dashboard:
- Log in to the Cloudflare dashboard.
- Go to My Profile > API Tokens.
- Select the three-dot menu on your Wrangler token.
- Select Delete.
whoami
Retrieve your user information and test your authentication configuration.
1 | wrangler whoami |
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
versions
Note
The minimum required wrangler version to use these commands is 3.40.0. For versions before 3.73.0, you will need to add the --x-versions flag.
upload
Upload a new version of your Worker that is not deployed immediately.
1 | wrangler versions upload [OPTIONS] |
-
--tagstring optional- Add a version tag. Accepts empty string.
-
--messagestring optional- Add a version message. Accepts empty string.
-
--preview-aliasstring optional- Creates an alias to this version.
-
--namestring optional- Perform on a specific Worker rather than inheriting from the Wrangler configuration file.
-
--envstring optional-
Perform on a specific environment.
Note
If you’re using the Cloudflare Vite plugin, you select the environment at dev or build time via the
CLOUDFLARE_ENVenvironment variable rather than the--envflag. Otherwise, environments are defined in your Worker config file as usual. For more detail on using environments with the Cloudflare Vite plugin, refer to the plugin documentation.
-
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
deploy
Deploy a previously created version of your Worker all at once or create a gradual deployment to incrementally shift traffic to a new version by following an interactive prompt.
1 | wrangler versions deploy [OPTIONS] |
--namestring optional- Perform on a specific Worker rather than inheriting from the Wrangler configuration file.
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
Note
The non-interactive version of this prompt is: wrangler versions deploy version-id-1@percentage-1% version-id-2@percentage-2 -y
For example: wrangler versions deploy 095f00a7-23a7-43b7-a227-e4c97cab5f22@10% 1a88955c-2fbd-4a72-9d9b-3ba1e59842f2@90% -y
list
Retrieve details for the 10 most recent versions. Details include Version ID, Created on, Author, Source, and optionally, Tag or Message.
1 | wrangler versions list [OPTIONS] |
--namestring optional- Perform on a specific Worker rather than inheriting from the Wrangler configuration file.
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
secret put
Create or replace a secret for a Worker. Creates a new version with modified secrets without deploying the Worker.
1 | wrangler versions secret put <KEY> [OPTIONS] |
KEYstring required- The variable name for this secret to be accessed in the Worker.
--namestring optional- Perform on a specific Worker rather than inheriting from the Wrangler configuration file.
--envstring optional- Perform on a specific environment.
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
secret delete
Delete a secret for a Worker. Creates a new version with modified secrets without deploying the Worker.
1 | wrangler versions delete <KEY> [OPTIONS] |
KEYstring required- The variable name for this secret to be accessed in the Worker.
--namestring optional- Perform on a specific Worker rather than inheriting from the Wrangler configuration file.
--envstring optional- Perform on a specific environment.
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
secret bulk
Upload multiple secrets for a Worker at once. Creates a new version with modified secrets without deploying the Worker.
1 | wrangler versions secret bulk <FILENAME> [OPTIONS] |
-
FILENAMEstring optional- A file containing either JSON or the .env format
- The JSON file containing key-value pairs to upload as secrets, in the form
{"SECRET_NAME": "secret value", ...}. - The
.envfile containing key-value pairs to upload as secrets, in the formSECRET_NAME=secret value. - If omitted, Wrangler expects to receive input from
stdinrather than a file.
-
--namestring optional- Perform on a specific Worker rather than inheriting from the Wrangler configuration file.
-
--envstring optional- Perform on a specific environment.
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
triggers
Note
The minimum required wrangler version to use these commands is 3.40.0. For versions before 3.73.0, you will need to add the --x-versions flag.
deploy
Apply changes to triggers (Routes or domains and Cron Triggers) when using wrangler versions upload.
1 | wrangler triggers deploy [OPTIONS] |
--namestring optional- Perform on a specific Worker rather than inheriting from the Wrangler configuration file.
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
deployments
Deployments track the version(s) of your Worker that are actively serving traffic.
list
Note
The minimum required wrangler version to use these commands is 3.40.0. For versions before 3.73.0, you will need to add the --x-versions flag.
Retrieve details for the 10 most recent deployments. Details include Created on, Author, Source, an optional Message, and metadata about the Version(s) in the deployment.
1 | wrangler deployments list [OPTIONS] |
--namestring optional- Perform on a specific Worker rather than inheriting from the Wrangler configuration file.
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
status
Retrieve details for the most recent deployment. Details include Created on, Author, Source, an optional Message, and metadata about the Version(s) in the deployment.
1 | wrangler deployments status |
--namestring optional- Perform on a specific Worker rather than inheriting from the Wrangler configuration file.
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
rollback
Warning
A rollback will immediately create a new deployment with the specified version of your Worker and become the active deployment across all your deployed routes and domains. This change will not affect work in your local development environment.
1 | wrangler rollback [<VERSION_ID>] [OPTIONS] |
VERSION_IDstring optional- The ID of the version you wish to roll back to. If not supplied, the
rollbackcommand defaults to the version uploaded before the latest version.
- The ID of the version you wish to roll back to. If not supplied, the
--namestring optional- Perform on a specific Worker rather than inheriting from the Wrangler configuration file.
--messagestring optional- Add message for rollback. Accepts empty string. When specified, interactive prompts for rollback confirmation and message are skipped.
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
dispatch namespace
list
List all dispatch namespaces.
1 | wrangler dispatch-namespace list |
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
get
Get information about a dispatch namespace.
1 | wrangler dispatch-namespace get <NAME> |
NAMEstring required- The name of the dispatch namespace to get details about.
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
create
Create a dispatch namespace.
1 | wrangler dispatch-namespace create <NAME> |
NAMEstring required- The name of the dispatch namespace to create.
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
delete
Delete a dispatch namespace.
1 | wrangler dispatch-namespace get <NAME> |
Note
You must delete all user Workers in the dispatch namespace before it can be deleted.
NAMEstring required- The name of the dispatch namespace to delete.
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
rename
Rename a dispatch namespace.
1 | wrangler dispatch-namespace get <OLD_NAME> <NEW_NAME> |
OLD_NAMEstring required- The previous name of the dispatch namespace.
NEW_NAMEstring required- The new name of the dispatch namespace.
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
mtls-certificate
Manage client certificates used for mTLS connections in subrequests.
These certificates can be used in mtls_certificate bindings, which allow a Worker to present the certificate when establishing a connection with an origin that requires client authentication (mTLS).
upload
Upload a client certificate.
1 | wrangler mtls-certificate upload --cert <PATH> --key <PATH> [OPTIONS] |
--certstring required- A path to the TLS certificate to upload. Certificate chains are supported.
--keystring required- A path to the private key to upload.
--namestring optional- The name assigned to the mTLS certificate at upload.
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
The following is an example of using the upload command to upload an mTLS certificate.
1 | npx wrangler mtls-certificate upload --cert cert.pem --key key.pem --name my-origin-cert |
1 | Uploading mTLS Certificate my-origin-cert... |
You can then add this certificate as a binding in your Wrangler configuration file:
-
wrangler.jsonc
1
2
3
4
5
6
7
8{
"mtls_certificates": [
{
"binding": "MY_CERT",
"certificate_id": "99f5fef1-6cc1-46b8-bd79-44a0d5082b8d"
}
]
} -
wrangler.toml
1
2
3mtls_certificates = [
{ binding = "MY_CERT", certificate_id = "99f5fef1-6cc1-46b8-bd79-44a0d5082b8d" }
]
Note that the certificate and private keys must be in separate (typically .pem) files when uploading.
list
List mTLS certificates associated with the current account ID.
1 | wrangler mtls-certificate list |
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
The following is an example of using the list command to upload an mTLS certificate.
1 | npx wrangler mtls-certificate list |
1 | ID: 99f5fef1-6cc1-46b8-bd79-44a0d5082b8d |
delete
Delete a client certificate.
1 | wrangler mtls-certificate delete {--id <ID|--name <NAME>} |
--idstring- The ID of the mTLS certificate.
--namestring- The name assigned to the mTLS certificate at upload.
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
The following is an example of using the delete command to delete an mTLS certificate.
1 | npx wrangler mtls-certificate delete --id 99f5fef1-6cc1-46b8-bd79-44a0d5082b8d |
1 | Are you sure you want to delete certificate 99f5fef1-6cc1-46b8-bd79-44a0d5082b8d (my-origin-cert)? [y/n] |
cert
Manage mTLS client certificates and Certificate Authority (CA) chain certificates used for secured connections.
These certificates can be used in Hyperdrive configurations, enabling them to present the certificate when connecting to an origin database that requires client authentication (mTLS) or a custom Certificate Authority (CA).
upload mtls-certificate
Upload a client certificate.
1 | wrangler cert upload mtls-certificate --cert <PATH> --key <PATH> [OPTIONS] |
--certstring required- A path to the TLS certificate to upload. Certificate chains are supported.
--keystring required- A path to the private key to upload.
--namestring optional- The name assigned to the mTLS certificate at upload.
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
The following is an example of using the upload command to upload an mTLS certificate.
1 | npx wrangler cert upload --cert cert.pem --key key.pem --name my-origin-cert |
1 | Uploading mTLS Certificate my-origin-cert... |
Note that the certificate and private keys must be in separate (typically .pem) files when uploading.
upload certificate-authority
Upload a client certificate.
1 | wrangler cert upload certificate-authority --ca-cert <PATH> [OPTIONS] |
-
--ca-certstring required- A path to the Certificate Authority (CA) chain certificate to upload.
-
--namestring optional- The name assigned to the mTLS certificate at upload.
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
The following is an example of using the upload command to upload an CA certificate.
1 | npx wrangler cert upload certificate-authority --ca-cert server-ca-chain.pem --name SERVER_CA_CHAIN |
1 | Uploading CA Certificate SERVER_CA_CHAIN... |
list
List mTLS certificates associated with the current account ID. This will display both mTLS certificates and CA certificates.
1 | wrangler cert list |
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
The following is an example of using the list command to upload an mTLS or CA certificate.
1 | npx wrangler cert list |
1 | ID: 99f5fef1-6cc1-46b8-bd79-44a0d5082b8d |
delete
Delete a client certificate.
1 | wrangler cert delete {--id <ID|--name <NAME>} |
--idstring- The ID of the mTLS or CA certificate.
--namestring- The name assigned to the mTLS or CA certificate at upload.
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
The following is an example of using the delete command to delete an mTLS or CA certificate.
1 | npx wrangler cert delete --id 99f5fef1-6cc1-46b8-bd79-44a0d5082b8d |
1 | Are you sure you want to delete certificate 99f5fef1-6cc1-46b8-bd79-44a0d5082b8d (my-origin-cert)? [y/n] |
types
Generate types based on your Worker configuration, including Env types based on your bindings, module rules, and runtime types based on thecompatibility_date and compatibility_flags in your config file.
1 | wrangler types [<PATH>] [OPTIONS] |
Note
If you are running a version of Wrangler that is greater than 3.66.0 but below 4.0.0, you will need to include the --experimental-include-runtime flag. During its experimental release, runtime types were output to a separate file (.wrangler/types/runtime.d.ts by default). If you have an older version of Wrangler, you can access runtime types through the @cloudflare/workers-types package.
-
PATHstring (default: `./worker-configuration.d.ts`)- The path to where types for your Worker will be written.
- The path must have a
d.tsextension.
-
--env-interfacestring (default: `Env`)- The name of the interface to generate for the environment object.
- Not valid if the Worker uses the Service Worker syntax.
-
--include-runtimeboolean (default: true)- Whether to generate runtime types based on the
compatibility_dateandcompatibility_flagsin your config file.
- Whether to generate runtime types based on the
-
--include-envboolean (default: true)- Whether to generate
Envtypes based on your Worker bindings.
- Whether to generate
-
--strict-varsboolean optional (default: true)- Control the types that Wrangler generates for
varsbindings. - If
true, (the default) Wrangler generates literal and union types for bindings (e.g.myVar: 'my dev variable' | 'my prod variable'). - If
false, Wrangler generates generic types (e.g.myVar: string). This is useful when variables change frequently, especially when working across multiple environments.
- Control the types that Wrangler generates for
-
--config,-cstring[] optional- Path(s) to Wrangler configuration file. If the Worker you are generating types for has service bindings or bindings to Durable Objects, you can also provide the paths to those configuration files so that the generated
Envtype will include RPC types. For example, given a Worker with a service binding,wrangler types -c wrangler.toml -c ../bound-worker/wrangler.tomlwill generate anEnvtype like this:
1
2
3interface Env {
SERVICE_BINDING: Service<import("../bound-worker/src/index").Entrypoint>;
}Note
Currently, this only works if your service binding targets a named entrypoint, rather than the default export. If you are unable to use named entrypoints, we recommend you extend your
Envtype in a separate file in order to manually provide those types without risk of being overwritten by subsequent runs ofwrangler types. This is a temporary limitation we are working to fix. - Path(s) to Wrangler configuration file. If the Worker you are generating types for has service bindings or bindings to Durable Objects, you can also provide the paths to those configuration files so that the generated
telemetry
Cloudflare collects anonymous usage data to improve Wrangler. You can learn more about this in our data policy.
You can manage sharing of usage data at any time using these commands.
disable
Disable telemetry collection for Wrangler.
1 | wrangler telemetry disable |
enable
Enable telemetry collection for Wrangler.
1 | wrangler telemetry enable |
status
Check whether telemetry collection is currently enabled. The return result is specific to the directory where you have run the command.
This will resolve the global status set by wrangler telemetry disable / enable, the environment variable WRANGLER_SEND_METRICS, and the send_metrics key in the Wrangler configuration file.
1 | wrangler telemetry status |
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
check
startup
Generate a CPU profile of your Worker’s startup phase.
After you run wrangler check startup, you can import the profile into Chrome DevTools or open it directly in VSCode to view a flamegraph of your Worker’s startup phase. Additionally, when a Worker deployment fails with a startup time error Wrangler will automatically generate a CPU profile for easy investigation.
1 | wrangler check startup |
--argsstring optional- To customise the way
wrangler check startupbuilds your Worker for analysis, provide the exact arguments you use when deploying your Worker withwrangler deploy, or your Pages project withwrangler pages functions build. For instance, if you deploy your Worker withwrangler deploy --no-bundle, you should usewrangler check startup --args="--no-bundle"to profile the startup phase.
- To customise the way
--workerstring optional- If you don’t use Wrangler to deploy your Worker, you can use this argument to provide a Worker bundle to analyse. This should be a file path to a serialized multipart upload, with the exact same format as the API expects.
--pagesboolean optional- If you don’t use a Wrangler config file with your Pages project (i.e. a Wrangler config file containing
pages_build_output_dir), use this flag to forcewrangler check startupto treat your project as a Pages project.
- If you don’t use a Wrangler config file with your Pages project (i.e. a Wrangler config file containing
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.