Commands
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. (Deprecated — usenpm create cloudflare@latestinstead)generate- Create a Wrangler project using an existing Workers template ↗.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.publish- Publish your Worker to Cloudflare.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.tail- Start a session to livestream logs from a deployed Worker.pages- Configure Cloudflare Pages.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.types- Generate types from bindings and module rules in configuration.
This page provides a reference for Wrangler commands.
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.
npx wrangler <COMMAND> <SUBCOMMAND> [PARAMETERS] [OPTIONS]yarn wrangler <COMMAND> <SUBCOMMAND> [PARAMETERS] [OPTIONS]pnpm wrangler <COMMAND> <SUBCOMMAND> [PARAMETERS] [OPTIONS]You can add Wrangler commands that you use often as scripts in your project’s package.json file:
{ ... "scripts": { "deploy": "wrangler deploy", "dev": "wrangler dev" } ...}You can then run them using your package manager of choice:
npm run deployyarn run deploypnpm run deployOpen the Cloudflare developer documentation in your default browser.
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.
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.
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 generatedwrangler.tomlconfiguration file.
- 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.
Create a new project using an existing Workers template ↗.
wrangler generate [<NAME>] [TEMPLATE]NAMEstring optional (default: name of working directory)- The name of the Workers project. This is both the directory name and
nameproperty in the generatedwrangler.tomlconfiguration file.
- The name of the Workers project. This is both the directory name and
TEMPLATEstring optional- The URL of a GitHub template, with a default worker-template ↗. Browse a list of available templates on the cloudflare/workers-sdk ↗ repository.
Interact with Cloudflare’s D1 service.
Creates a new D1 database, and provides the binding and UUID that you will put in your wrangler.toml file.
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).
Get information about a D1 database, including the current database size and state.
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 all D1 databases in your account.
wrangler d1 list [OPTIONS]--jsonboolean optional- Return output as JSON rather than a table.
Delete a D1 database.
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 a query on a D1 database.
wrangler d1 execute <DATABASE_NAME> [OPTIONS]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 Wrangler.toml).
- Execute commands/files against a preview D1 database (as defined by
--batch-sizenumber optional- Number of queries to send in a single batch.
Export a D1 database or table’s schema and/or content to a .sql file.
wrangler d1 export <DATABASE_NAME> [OPTIONS]DATABASE_NAMEstring required- The name of the D1 database to export.
--remoteboolean (default: false) optional- Execute commands/files against a remote D1 database for use with wrangler dev —remote.
--outputstring optional- 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
Restore a database to a specific point-in-time using Time Travel.
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.
Inspect the current state of a database for a specific point-in-time using Time Travel.
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.
Initiate a D1 backup.
wrangler d1 backup create <DATABASE_NAME>DATABASE_NAMEstring required- The name of the D1 database to backup.
List all available backups.
wrangler d1 backup list <DATABASE_NAME>DATABASE_NAMEstring required- The name of the D1 database to list the backups of.
Restore a backup into a D1 database.
wrangler d1 backup restore <DATABASE_NAME> <BACKUP_ID>DATABASE_NAMEstring required- The name of the D1 database to restore the backup into.
BACKUP_IDstring required- The ID of the backup you wish to restore.
Download existing data to your local machine.
wrangler d1 backup download <DATABASE_NAME> <BACKUP_ID>DATABASE_NAMEstring required- The name of the D1 database you wish to download the backup of.
BACKUP_IDstring required- The ID of the backup you wish to download.
--outputstring optional- The
.sqlite3file to write to (defaults to'<DB_NAME>.<SHORT_BACKUP_ID>.sqlite3').
- The
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.
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.
View a list of unapplied migration files.
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.
--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_idinwrangler.toml).
- Show the list of unapplied migration files on your preview D1 database (as defined by
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.
wrangler d1 migrations apply <DATABASE_NAME> [OPTIONS]DATABASE_NAMEstring required- The name of the D1 database you wish to apply your migrations on.
--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_idinwrangler.toml).
- Execute any unapplied migrations on your preview D1 database (as defined by
--batch-sizenumber optional- Number of queries to send in a single batch.
Manage Hyperdrive database configurations.
Create a new Hyperdrive configuration.
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
--hoststring optional- The hostname or IP address Hyperdrive should connect to.
--portnumber optional- The database port to connect to.
--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.
--userstring optional- The username used to authenticate to the database.
--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
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
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.
Update an existing Hyperdrive configuration.
wrangler hyperdrive update <ID> [OPTIONS]IDstring required- The ID of the Hyperdrive configuration to update.
--namestring optional- The new name of the Hyperdrive configuration.
--origin-hoststring optional- The new database hostname or IP address Hyperdrive should connect to.
--origin-portstring optional- The new database port to connect to.
--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.
List all Hyperdrive configurations.
wrangler hyperdrive listDelete an existing Hyperdrive configuration.
wrangler hyperdrive delete <ID>IDstring required- The name of the Hyperdrive configuration to delete.
Get an existing Hyperdrive configuration.
wrangler hyperdrive get <ID>IDstring required- The name of the Hyperdrive configuration to get.
Interact with a Vectorize vector database.
Creates a new vector index, and provides the binding and name that you will put in your wrangler.toml file.
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 or reused after the deletion of an index.
--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 all Vectorize indexes in your account, including the configured dimensions and distance metric.
npx wrangler vectorize list--deprecated-v1boolean optional- List legacy Vectorize indexes. Please note that legacy Vectorize indexes are on a deprecation path.
Get details about an individual index, including its configuration.
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.
Get some additional information about an individual index, including the vector count and details about the last processed mutation.
npx wrangler vectorize info <INDEX_NAME>INDEX_NAMEstring required- The name of the index to fetch details for.
Delete a Vectorize index.
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 vectors into an index.
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 vectors into an index. Existing vectors in the index would be overwritten.
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 a Vectorize index for similar vectors.
npx wrangler vectorize query <INDEX_NAME> [OPTIONS]INDEX_NAMEstring required- The name of the Vectorize index to query.
--vectorarray required- Vector against which the Vectorize index is queried.
--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:
Fetch vectors from a Vectorize index using the provided ids.
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 in a Vectorize index using the provided ids.
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.
Enable metadata filtering on the specified property.
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 properties on which metadata filtering is enabled.
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.
Disable metadata filtering on the specified property.
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.
Start a local server for developing your Worker.
wrangler dev [<SCRIPT>] [OPTIONS]SCRIPTstring- The path to an entry point for your Worker. Only required if your
wrangler.tomldoes not include amainkey (for example,main = "index.js").
- The path to an entry point for your Worker. Only required if your
--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.
--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.
--legacy-assetsstring optional deprecated, use `--assets`- Folder of static assets to be served.
--sitestring optional deprecated, use `--assets`- Folder of static assets for Workers Sites.
--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:123makes thegit_hashandtestvariables available in your Worker’senv. - This flag is an alternative to defining
varsin yourwrangler.toml. 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 yourwrangler.toml. 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.
--node-compatboolean optional- Enable Node.js compatibility.
--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=*+*+*+*+*.
- 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.
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 your Worker to Cloudflare.
wrangler deploy [<SCRIPT>] [OPTIONS]SCRIPTstring- The path to an entry point for your Worker. Only required if your
wrangler.tomldoes not include amainkey (for example,main = "index.js").
- The path to an entry point for your Worker. Only required if your
--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.
--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.
--legacy-assetsstring optional deprecated, use `--assets`- Folder of static assets to be served.
--sitestring optional deprecated, use `--assets`- Folder of static assets for Workers Sites.
--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 yourwrangler.toml. 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 yourwrangler.toml. 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.
--node-compatboolean optional- Enable node.js compatibility.
--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 or bindings in the Cloudflare dashboard, Wrangler will override them the next time you deploy. If you want to disable this behaviour set
keep-varstotrue.
--dispatch-namespacestring optional- Specify the Workers for Platforms dispatch namespace to upload this Worker to.
Publish your Worker to Cloudflare.
wrangler publish [OPTIONS]Delete your Worker and all associated Cloudflare developer platform resources.
wrangler delete [<SCRIPT>] [OPTIONS]SCRIPTstring- The path to an entry point for your Worker. Only required if your
wrangler.tomldoes not include amainkey (for example,main = "index.js").
- The path to an entry point for your Worker. Only required if your
--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
Manage Workers KV namespaces.
Create a new namespace.
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 is an example of using the create command to create a KV namespace called MY_KV.
npx wrangler kv namespace create "MY_KV"🌀 Creating namespace with title "worker-MY_KV"✨ Success!Add the following to your configuration file in your kv_namespaces array:kv_namespaces = [ { binding = "MY_KV", id = "e29b263ab50e42ce9b637fa8370175e8" }]The following is an example of using the create command to create a preview KV namespace called MY_KV.
npx wrangler kv namespace create "MY_KV" --preview🌀 Creating namespace with title "my-site-MY_KV_preview"✨ Success!Add the following to your configuration file in your kv_namespaces array:kv_namespaces = [ { binding = "MY_KV", preview_id = "15137f8edf6c09742227e99b08aaf273" }]List all KV namespaces associated with the current account ID.
wrangler kv namespace listThe following is an example that passes the Wrangler command through the jq command:
npx wrangler kv namespace list | jq "."[ { "id": "06779da6940b431db6e566b4846d64db", "title": "TEST_NAMESPACE" }, { "id": "32ac1b3c2ed34ed3b397268817dea9ea", "title": "STATIC_CONTENT" }]Delete a given namespace.
wrangler kv namespace delete {--binding=<BINDING>|--namespace-id=<NAMESPACE_ID>} [OPTIONS]--bindingstring- The binding name of the namespace, as stored in the
wrangler.tomlfile, to delete.
- The binding name of the namespace, as stored in the
--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 is an example of deleting a KV namespace called MY_KV.
npx wrangler kv namespace delete --binding=MY_KVAre you sure you want to delete namespace f7b02e7fc70443149ac906dd81ec1791? [y/n]yesDeleting namespace f7b02e7fc70443149ac906dd81ec1791Deleted namespace f7b02e7fc70443149ac906dd81ec1791The following is an example of deleting a preview KV namespace called MY_KV.
npx wrangler kv namespace delete --binding=MY_KV --previewAre you sure you want to delete namespace 15137f8edf6c09742227e99b08aaf273? [y/n]yesDeleting namespace 15137f8edf6c09742227e99b08aaf273Deleted namespace 15137f8edf6c09742227e99b08aaf273Manage key-value pairs within a Workers KV namespace.
Write a single key-value pair to a particular namespace.
wrangler kv key put <KEY> {<VALUE>|--path=<PATH>} {--binding=<BINDING>|--namespace-id=<NAMESPACE_ID>} [OPTIONS]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.tomlfile, to delete.
- The binding name of the namespace, as stored in the
--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.
--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 optional- Interact with locally persisted data.
--persist-tostring optional- Specify directory for locally persisted data.
The following is an example that puts a key-value into the namespace with binding name of MY_KV.
npx wrangler kv key put --binding=MY_KV "my-key" "some-value"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.
npx wrangler kv key put --binding=MY_KV --preview "my-key" "some-value"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.
npx wrangler kv key put --binding=MY_KV "my-key" "some-value" --ttl=10000Writing 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.
npx wrangler kv key put --binding=MY_KV "my-key" --path=value.txtWriting the contents of value.txt to the key "my-key" on namespace f7b02e7fc70443149ac906dd81ec1791.Output a list of all keys in a given namespace.
wrangler kv key list {--binding=<BINDING>|--namespace-id=<NAMESPACE_ID>} [OPTIONS]--bindingstring- The binding name of the namespace, as stored in the
wrangler.tomlfile, to delete.
- The binding name of the namespace, as stored in the
--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.
--prefixstring optional- Only list keys that begin with the given prefix.
--localboolean optional- Interact with locally persisted data.
--persist-tostring optional- Specify directory for locally persisted data.
Below is an example that passes the Wrangler command through the jq command:
npx wrangler kv key list --binding=MY_KV --prefix="public" | jq "."[ { "name": "public_key" }, { "name": "public_key_with_expiration", "expiration": "2019-09-10T23:18:58Z" }]Read a single value by key from the given namespace.
wrangler kv key get <KEY> {--binding=<BINDING>|--namespace-id=<NAMESPACE_ID>} [OPTIONS]KEYstring required- The key value to get.
--bindingstring- The binding name of the namespace, as stored in the
wrangler.tomlfile, to get from.
- The binding name of the namespace, as stored in the
--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 optional- Interact with locally persisted data.
--persist-tostring optional- Specify directory for locally persisted data.
The following is an example that gets the value of the "my-key" key from the KV namespace with binding name MY_KV.
npx wrangler kv key get --binding=MY_KV "my-key"valueRemove a single key value pair from the given namespace.
wrangler kv key delete <KEY> {--binding=<BINDING>|--namespace-id=<NAMESPACE_ID>} [OPTIONS]KEYstring required- The key value to get.
--bindingstring- The binding name of the namespace, as stored in the
wrangler.tomlfile, to delete.
- The binding name of the namespace, as stored in the
--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.
--localboolean optional- Interact with locally persisted data.
--persist-tostring optional- Specify directory for locally persisted data.
The following is an example that deletes the key-value pair with key "my-key" from the KV namespace with binding name MY_KV.
npx wrangler kv key delete --binding=MY_KV "my-key"Deleting the key "my-key" on namespace f7b02e7fc70443149ac906dd81ec1791.Manage multiple key-value pairs within a Workers KV namespace in batches.
Write a JSON file containing an array of key-value pairs to the given namespace.
wrangler kv bulk put <FILENAME> {--binding=<BINDING>|--namespace-id=<NAMESPACE_ID>} [OPTIONS]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.tomlfile, to delete.
- The binding name of the namespace, as stored in the
--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.
--localboolean optional- Interact with locally persisted data.
--persist-tostring optional- Specify directory for locally persisted data.
This command takes a JSON file as an argument with a list of key-value pairs to upload. An example of JSON input:
[ { "key": "test_key", "value": "test_value", "expiration_ttl": 3600 }]KV namespace values can only store strings. In order to save complex a value, stringify it to JSON:
[ { "key": "test_key", "value": "{\"name\": \"test_value\"}", "expiration_ttl": 3600 }]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
The following is an example of writing all the key-value pairs found in the allthethingsupload.json file.
npx wrangler kv bulk put --binding=MY_KV allthethingsupload.jsonSuccess!Delete all keys read from a JSON file within a given namespace.
wrangler kv bulk delete <FILENAME> {--binding=<BINDING>|--namespace-id=<NAMESPACE_ID>} [OPTIONS]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.tomlfile, to delete.
- The binding name of the namespace, as stored in the
--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.
--localboolean optional- Interact with locally persisted data.
--persist-tostring optional- Specify directory for locally persisted data.
This command takes a JSON file as an argument containing an array of keys to delete.
The following is an example of the JSON input:
["test_key_1", "test_key_2"]The following is an example of deleting all the keys found in the allthethingsdelete.json file.
npx wrangler kv bulk delete --binding=MY_KV allthethingsdelete.json? Are you sure you want to delete all keys in allthethingsdelete.json from kv-namespace with id "f7b02e7fc70443149ac906dd81ec1791"? › (Y/n)Success!Interact with buckets in an R2 store.
Create a new R2 bucket.
wrangler r2 bucket create <NAME>NAMEstring required- The name of the new 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.
Delete an R2 bucket.
wrangler r2 bucket delete <NAME>NAMEstring required- The name of the R2 bucket to delete.
List R2 bucket in the current account.
wrangler r2 bucket listCreate an event notification rule for an R2 bucket.
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).
Remove an event notification rule from a bucket’s event notification configuration.
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.
List the event notification rules for a bucket.
wrangler r2 bucket notification list <NAME>NAMEstring required- The name of the R2 bucket to get event notification rules for.
Enable Sippy incremental migration for a bucket.
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 this R2 bucket is located, 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.
Disable Sippy incremental migration for a bucket.
wrangler r2 bucket sippy disable <NAME>NAMEstring required- The name of the R2 bucket to disable Sippy.
Get the status of Sippy incremental migration for a bucket.
wrangler r2 bucket sippy get <NAME>NAMEstring required- The name of the R2 bucket to get the status of Sippy.
Interact with R2 objects.
Fetch an object from an R2 bucket.
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 optional- Interact with locally persisted data.
--persist-tostring optional- Specify directory for locally persisted data.
Create an object in an R2 bucket.
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 optional- Interact with locally persisted data.
--persist-tostring optional- Specify directory for locally persisted data.
Delete an object in an R2 bucket.
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 optional- Interact with locally persisted data.
--persist-tostring optional- Specify directory for locally persisted data.
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.
Create or replace a secret for a Worker.
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
wrangler.toml.
- Perform on a specific Worker rather than inheriting from
-
--envstring optional- Perform on a specific environment.
When running this command, you will be prompted to input the secret’s value:
npx wrangler secret put FOO? Enter a secret value: › ***🌀 Creating the secret for script worker-app✨ Success! Uploaded secret FOOThe put command can also receive piped input. For example:
echo "-----BEGIN PRIVATE KEY-----\nM...==\n-----END PRIVATE KEY-----\n" | wrangler secret put PRIVATE_KEYDelete a secret for a Worker.
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
wrangler.toml.
- Perform on a specific Worker rather than inheriting from
-
--envstring optional- Perform on a specific environment.
List the names of all the secrets for a Worker.
wrangler secret list [OPTIONS]-
--namestring optional- Perform on a specific Worker rather than inheriting from
wrangler.toml.
- Perform on a specific Worker rather than inheriting from
-
--envstring optional- Perform on a specific environment
The following is an example of listing the secrets for the current Worker.
npx wrangler secret list[ { "name": "FOO", "type": "secret_text" }]Upload multiple secrets for a Worker at once.
wrangler secret:bulk [<FILENAME>] [OPTIONS]-
FILENAMEstring optional- The JSON file containing key-value pairs to upload as secrets, in the form
{"SECRET_NAME": "secret value", ...}. - If omitted, Wrangler expects to receive input from
stdinrather than a file.
- The JSON file containing key-value pairs to upload as secrets, in the form
-
--namestring optional- Perform on a specific Worker rather than inheriting from
wrangler.toml.
- Perform on a specific Worker rather than inheriting from
-
--envstring optional- Perform on a specific environment.
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.
{ "secret-name-1": "secret-value-1", "secret-name-2": "secret-value-2"}npx wrangler secret:bulk < secrets.json🌀 Creating the secrets for the Worker "script-name"✨ Successfully created secret for key: secret-name-1...🚨 Error uploading secret for key: secret-name-1✨ Successfully created secret for key: secret-name-2
Finished processing secrets JSON file:✨ 1 secrets successfully uploaded🚨 1 secrets failed to uploadStart a session to livestream logs from a deployed Worker.
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.
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.
If sampling persists after using options to filter messages, consider using instant logs ↗.
Configure Cloudflare Pages.
Develop your full-stack Pages application locally.
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).
--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.
List your Pages projects.
wrangler pages project listCreate a new Cloudflare Pages project.
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.
Delete a Cloudflare Pages project.
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
List deployments in your Cloudflare Pages project.
wrangler pages deployment list [--project-name <PROJECT_NAME>]--project-namestring optional- The name of the project you would like to list deployments for.
Start a session to livestream logs from your deployed Pages Functions.
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
After starting wrangler pages deployment tail, you will receive a live stream of console and exception logs for each request your Functions receive.
Deploy a directory of static assets as a Pages deployment.
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.tomlfile. Refer to the Pages Functions configuration guide for more information.
- 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
--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.
Publish a directory of static assets as a Pages deployment.
wrangler pages publish [<DIRECTORY>] [OPTIONS]Create or update a secret for a Pages project.
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.
Delete a secret from a Pages project.
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.
List the names of all the secrets for a Pages project.
wrangler pages secret list [OPTIONS]-
--project-namestring optional- The name of your Pages project.
Upload multiple secrets for a Pages project at once.
wrangler pages secret bulk [<FILENAME>] [OPTIONS]-
FILENAMEstring optional- The JSON file containing key-value pairs to upload as secrets, in the form
{"SECRET_NAME": "secret value", ...}. - If omitted, Wrangler expects to receive input from
stdinrather than a file.
- The JSON file containing key-value pairs to upload as secrets, in the form
-
--project-namestring optional- The name of your Pages project.
Manage your Workers Queues configurations.
Create a new Queue.
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.
Delete an existing queue.
wrangler queues delete <name> [OPTIONS]namestring required- The name of the queue to delete.
List all queues in the current account.
wrangler queues list [OPTIONS]Manage queue consumer configurations.
Add a Worker script as a queue consumer.
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.
Remove a consumer from a queue.
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.
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.
wrangler login [OPTIONS]--scopes-liststring optional- List all the available OAuth scopes with descriptions.
--scopes $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,
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.
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:
npx wrangler login ⛅️ wrangler 2.1.6-------------------Attempting to login via OAuth...Opening a link in your default browser: https://dash.cloudflare.com/oauth2/auth?xyz...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:
curl <LOCALHOST_URL>Remove Wrangler’s authorization for accessing your account. This command will invalidate your current OAuth token.
wrangler logoutIf 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.
Retrieve your user information and test your authentication configuration.
wrangler whoamiUpload a new version of your Worker that is not deployed immediately.
wrangler versions upload [OPTIONS]--tagstring optional- Add a version tag. Accepts empty string.
--messagestring optional- Add a version message. Accepts empty string.
--namestring optional- Perform on a specific Worker rather than inheriting from
wrangler.toml.
- Perform on a specific Worker rather than inheriting from
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.
wrangler versions deploy [OPTIONS]--namestring optional- Perform on a specific Worker rather than inheriting from
wrangler.toml.
- Perform on a specific Worker rather than inheriting from
Retrieve details for the 10 most recent versions. Details include Version ID, Created on, Author, Source, and optionally, Tag or Message.
wrangler versions list [OPTIONS]--namestring optional- Perform on a specific Worker rather than inheriting from
wrangler.toml.
- Perform on a specific Worker rather than inheriting from
Create or replace a secret for a Worker. Creates a new version with modified secrets without deploying the Worker.
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
wrangler.toml.
- Perform on a specific Worker rather than inheriting from
--envstring optional- Perform on a specific environment.
Delete a secret for a Worker. Creates a new version with modified secrets without deploying the Worker.
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
wrangler.toml.
- Perform on a specific Worker rather than inheriting from
--envstring optional- Perform on a specific environment.
Upload multiple secrets for a Worker at once. Creates a new version with modified secrets without deploying the Worker.
wrangler versions secret bulk <FILENAME> [OPTIONS]FILENAMEstring optional- The JSON file containing key-value pairs to upload as secrets, in the form
{"SECRET_NAME": "secret value", ...}. - If omitted, Wrangler expects to receive input from
stdinrather than a file.
- The JSON file containing key-value pairs to upload as secrets, in the form
--namestring optional- Perform on a specific Worker rather than inheriting from
wrangler.toml.
- Perform on a specific Worker rather than inheriting from
--envstring optional- Perform on a specific environment.
Apply changes to triggers (Routes or domains and Cron Triggers) when using wrangler versions upload.
wrangler triggers deploy [OPTIONS]--namestring optional- Perform on a specific Worker rather than inheriting from
wrangler.toml.
- Perform on a specific Worker rather than inheriting from
Deployments track the version(s) of your Worker that are actively serving traffic.
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.
wrangler deployments list [OPTIONS]--namestring optional- Perform on a specific Worker rather than inheriting from
wrangler.toml.
- Perform on a specific Worker rather than inheriting from
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.
wrangler deployments status--namestring optional- Perform on a specific Worker rather than inheriting from
wrangler.toml.
- Perform on a specific Worker rather than inheriting from
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
wrangler.toml.
- Perform on a specific Worker rather than inheriting from
--messagestring optional- Add message for rollback. Accepts empty string. When specified, interactive prompts for rollback confirmation and message are skipped.
List all dispatch namespaces.
wrangler dispatch-namespace listGet information about a dispatch namespace.
wrangler dispatch-namespace get <NAME>-
NAMEstring required- The name of the dispatch namespace to get details about.
Create a dispatch namespace.
wrangler dispatch-namespace create <NAME>-
NAMEstring required- The name of the dispatch namespace to create.
Delete a dispatch namespace.
wrangler dispatch-namespace get <NAME>-
NAMEstring required- The name of the dispatch namespace to delete.
Rename a dispatch namespace.
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.
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 a client certificate.
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 is an example of using the upload command to upload an mTLS certificate.
npx wrangler mtls-certificate upload --cert cert.pem --key key.pem --name my-origin-certUploading mTLS Certificate my-origin-cert...Success! Uploaded mTLS Certificate my-origin-certID: 99f5fef1-6cc1-46b8-bd79-44a0d5082b8dIssuer: CN=my-secured-origin.com,OU=my-team,O=my-org,L=San Francisco,ST=California,C=USExpires: 1/01/2025You can then add this certificate as a binding in your wrangler.toml:
mtls_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 mTLS certificates associated with the current account ID.
wrangler mtls-certificate listThe following is an example of using the list command to upload an mTLS certificate.
npx wrangler mtls-certificate listID: 99f5fef1-6cc1-46b8-bd79-44a0d5082b8dName: my-origin-certIssuer: CN=my-secured-origin.com,OU=my-team,O=my-org,L=San Francisco,ST=California,C=USCreated on: 1/01/2023Expires: 1/01/2025
ID: c5d004d1-8312-402c-b8ed-6194328d5cbeIssuer: CN=another-origin.com,OU=my-team,O=my-org,L=San Francisco,ST=California,C=USCreated on: 1/01/2023Expires: 1/01/2025Delete a client certificate.
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 is an example of using the delete command to delete an mTLS certificate.
npx wrangler mtls-certificate delete --id 99f5fef1-6cc1-46b8-bd79-44a0d5082b8dAre you sure you want to delete certificate 99f5fef1-6cc1-46b8-bd79-44a0d5082b8d (my-origin-cert)? [y/n]yesDeleting certificate 99f5fef1-6cc1-46b8-bd79-44a0d5082b8d...Deleted certificate 99f5fef1-6cc1-46b8-bd79-44a0d5082b8d successfullyGenerate types from bindings and module rules in configuration.
wrangler types [<PATH>] [OPTIONS]-
PATHstring (default: `./worker-configuration.d.ts`)- The path to where the
Envtypes for your Worker will be written. - The path must have a
d.tsextension.
- The path to where the
-
--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.
-
--experimental-include-runtimestring optional (default: `./.wrangler/types/runtime.d.ts`)- The path to where the runtime types file will be written.
- Leave the path blank to use the default option, e.g.
npx wrangler types --x-include-runtime - A custom path must be relative to the project root, e.g.
./my-runtime-types.d.ts - A custom path must have a
d.tsextension.