Skip to content

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 — use npm create cloudflare@latest instead)
  • 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.

How to run Wrangler commands

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.

Terminal window
npx 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:

Terminal window
npm run deploy

docs

📚 Open Wrangler's command documentation in your browser

wrangler docs [search..]

Positionals

  • search [array] [default: []]

    Enter search terms (e.g. the wrangler command) you want to know more about

Options

  • -y, --yes [boolean]

    Takes you to the docs, even if search fails

init

📥 Initialize a basic Worker

wrangler init [name]

Positionals

  • name [string]

    The name of your worker

Options

  • -y, --yes [boolean]

    Answer "yes" to any prompts for new projects

  • --from-dash [string]

    The name of the Worker you wish to download from the Cloudflare dashboard for local development.


d1

Interact with Cloudflare’s D1 service.

d1 create

Create D1 database

wrangler d1 create <name>

Positionals

  • name [string] [required]

    The name of the new DB

Options

  • --location [string]

    A hint for the primary location of the new DB. Options:
    weur: Western Europe
    eeur: Eastern Europe
    apac: Asia Pacific
    oc: Oceania
    wnam: Western North America
    enam: Eastern North America

d1 info

Get information about a D1 database, including the current database size and state

wrangler d1 info <name>

Positionals

  • name [string] [required]

    The name of the DB

Options

  • --json [boolean] [default: false]

    return output as clean JSON

d1 list

List D1 databases

wrangler d1 list

Options

  • --json [boolean] [default: false]

    return output as clean JSON

d1 delete

Delete D1 database

wrangler d1 delete <name>

Positionals

  • name [string] [required]

    The name or binding of the DB

Options

  • -y, --skip-confirmation [boolean] [default: false]

    Skip confirmation

d1 execute

Execute a command or SQL file

wrangler d1 execute <database>

Positionals

  • database [string] [required]

    The name or binding of the DB

Options

  • -y, --yes [boolean]

    Answer "yes" to any prompts

  • --local [boolean]

    Execute commands/files against a local DB for use with wrangler dev

  • --remote [boolean]

    Execute commands/files against a remote DB for use with wrangler dev

  • --file [string]

    A .sql file to ingest

  • --command [string]

    A single SQL statement to execute

  • --persist-to [string]

    Specify directory to use for local persistence (for --local)

  • --json [boolean] [default: false]

    Return output as clean JSON

  • --preview [boolean] [default: false]

    Execute commands/files against a preview D1 DB

d1 export

Export the contents or schema of your database as a .sql file

wrangler d1 export <name>

Positionals

  • name [string] [required]

    The name or binding of the DB

Options

  • --local [boolean]

    Export from your local DB you use with wrangler dev

  • --remote [boolean]

    Export from your live D1

  • --no-schema [boolean]

    Only output table contents, not the DB schema

  • --no-data [boolean]

    Only output table schema, not the contents of the DBs themselves

  • --table [string]

    Specify which tables to include in export

  • --output [string] [required]

    Which .sql file to output to

d1 time-travel restore

Restore a database back to a specific point-in-time

wrangler d1 time-travel restore <database>

Positionals

  • database [string] [required]

    The name or binding of the DB

Options

  • --bookmark [string]

    Bookmark to use for time travel

  • --timestamp [string]

    accepts a Unix (seconds from epoch) or RFC3339 timestamp (e.g. 2023-07-13T08:46:42.228Z) to retrieve a bookmark for

  • --json [boolean] [default: false]

    return output as clean JSON

d1 time-travel info

Retrieve information about a database at a specific point-in-time using Time Travel

wrangler d1 time-travel info <database>

Positionals

  • database [string] [required]

    The name or binding of the DB

Options

  • --timestamp [string]

    accepts a Unix (seconds from epoch) or RFC3339 timestamp (e.g. 2023-07-13T08:46:42.228Z) to retrieve a bookmark for

  • --json [boolean] [default: false]

    return output as clean JSON

d1 backup create

Create a new D1 backup

wrangler d1 backup create <name>

Positionals

  • name [string] [required]

    The name or binding of the DB

d1 backup list

List your D1 backups

wrangler d1 backup list <name>

Positionals

  • name [string] [required]

    The name or binding of the DB

d1 backup restore

Restore a DB backup

wrangler d1 backup restore <name> <backup-id>

Positionals

  • name [string] [required]

    The name or binding of the DB

  • backup-id [string] [required]

    The Backup ID to restore

d1 backup download

Download a DB backup

wrangler d1 backup download <name> <backup-id>

Positionals

  • name [string] [required]

    The name or binding of the DB

  • backup-id [string] [required]

    The Backup ID to download

Options

  • --output [string]

    The .sqlite3 file to write to (defaults to '..sqlite3'

d1 migrations create

Create a new migration

wrangler d1 migrations create <database> <message>

Positionals

  • database [string] [required]

    The name or binding of the DB

  • message [string] [required]

    The Migration message

d1 migrations list

List your D1 migrations

wrangler d1 migrations list <database>

Positionals

  • database [string] [required]

    The name or binding of the DB

Options

  • --local [boolean]

    Execute commands/files against a local DB for use with wrangler dev

  • --remote [boolean]

    Execute commands/files against a remote DB for use with wrangler dev --remote

  • --preview [boolean] [default: false]

    Execute commands/files against a preview D1 DB

  • --persist-to [string]

    Specify directory to use for local persistence (you must use --local with this flag)

d1 migrations apply

Apply D1 migrations

wrangler d1 migrations apply <database>

Positionals

  • database [string] [required]

    The name or binding of the DB

Options

  • --local [boolean]

    Execute commands/files against a local DB for use with wrangler dev

  • --remote [boolean]

    Execute commands/files against a remote DB for use with wrangler dev --remote

  • --preview [boolean] [default: false]

    Execute commands/files against a preview D1 DB

  • --persist-to [string]

    Specify directory to use for local persistence (you must use --local with this flag)

  • --batch-size [deprecated] [number]

    Number of queries to send in a single batch


hyperdrive

Manage Hyperdrive database configurations.

create

Create a new Hyperdrive configuration.

wrangler hyperdrive create <CONFIG_NAME> [OPTIONS]
  • CONFIG_NAME string required
    • The name of the Hyperdrive configuration to create.
  • --connection-string string optional
    • The database connection string in the form postgres://user:password@hostname:port/database.
  • --host string optional
    • The hostname or IP address Hyperdrive should connect to.
  • --port number optional
    • The database port to connect to.
  • --scheme string optional
    • The scheme used to connect to the origin database, for example, postgresql or postgres.
  • --database string optional
    • The database (name) to connect to. For example, Postgres or defaultdb.
  • --user string optional
    • The username used to authenticate to the database.
  • --password string optional
    • The password used to authenticate to the database.
  • --access-client-id string 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.
  • --access-client-secret string 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.
  • --caching-disabled boolean optional
    • Disables the caching of SQL responses.
  • --max-age number optional
    • Specifies max duration for which items should persist in the cache, cannot be set when caching is disabled.
  • --swr number 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

Update an existing Hyperdrive configuration.

wrangler hyperdrive update <ID> [OPTIONS]
  • ID string required
    • The ID of the Hyperdrive configuration to update.
  • --name string optional
    • The new name of the Hyperdrive configuration.
  • --origin-host string optional
    • The new database hostname or IP address Hyperdrive should connect to.
  • --origin-port string optional
    • The new database port to connect to.
  • --database string optional
    • The new database (name) to connect to. For example, Postgres or defaultdb.
  • --origin-user string optional
    • The new username used to authenticate to the database.
  • --origin-password string optional
    • The new password used to authenticate to the database.
  • --access-client-id string 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.
  • --access-client-secret string 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.
  • --caching-disabled boolean optional
    • Disables the caching of SQL responses.
  • --max-age number optional
    • Specifies max duration for which items should persist in the cache, cannot be set when caching is disabled.
  • --swr number 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

List all Hyperdrive configurations.

wrangler hyperdrive list

delete

Delete an existing Hyperdrive configuration.

wrangler hyperdrive delete <ID>
  • ID string required
    • The name of the Hyperdrive configuration to delete.

get

Get an existing Hyperdrive configuration.

wrangler hyperdrive get <ID>
  • ID string required
    • The name of the Hyperdrive configuration to get.

vectorize

Interact with a Vectorize vector database.

vectorize create

Create a Vectorize index

wrangler vectorize create <name>

Positionals

  • name [string] [required]

    The name of the Vectorize index to create (must be unique).

Options

  • --dimensions [number]

    The dimension size to configure this index for, based on the output dimensions of your ML model.

  • --metric [string] [choices: "euclidean", "cosine", "dot-product"]

    The distance metric to use for searching within the index.

  • --preset [string] [choices: "@cf/baai/bge-small-en-v1.5", "@cf/baai/bge-base-en-v1.5", "@cf/baai/bge-large-en-v1.5", "openai/text-embedding-ada-002", "cohere/embed-multilingual-v2.0"]

    The name of an preset representing an embeddings model: Vectorize will configure the dimensions and distance metric for you when provided.

  • --description [string]

    An optional description for this index.

  • --json [boolean] [default: false]

    return output as clean JSON

  • --deprecated-v1 [boolean] [default: false]

    Create a deprecated Vectorize V1 index. This is not recommended and indexes created with this option need all other Vectorize operations to have this option enabled.

vectorize list

List your Vectorize indexes

wrangler vectorize list

Options

  • --json [boolean] [default: false]

    return output as clean JSON

  • --deprecated-v1 [boolean] [default: false]

    List deprecated Vectorize V1 indexes for your account.

vectorize get

Get a Vectorize index by name

wrangler vectorize get <name>

Positionals

  • name [string] [required]

    The name of the Vectorize index.

Options

  • --json [boolean] [default: false]

    return output as clean JSON

  • --deprecated-v1 [boolean] [default: false]

    Fetch a deprecated V1 Vectorize index. This must be enabled if the index was created with V1 option.

vectorize info

Get additional details about the index

wrangler vectorize info <name>

Positionals

  • name [string] [required]

    The name of the Vectorize index.

Options

  • --json [boolean] [default: false]

    return output as clean JSON

vectorize delete

Delete a Vectorize index

wrangler vectorize delete <name>

Positionals

  • name [string] [required]

    The name of the Vectorize index

Options

  • -y, --force [boolean] [default: false]

    Skip confirmation

  • --deprecated-v1 [boolean] [default: false]

    Delete a deprecated Vectorize V1 index.

vectorize insert

Insert vectors into a Vectorize index

wrangler vectorize insert <name>

Positionals

  • name [string] [required]

    The name of the Vectorize index.

Options

  • --file [string] [required]

    A file containing line separated json (ndjson) vector objects.

  • --batch-size [number] [default: 1000]

    Number of vector records to include when sending to the Cloudflare API.

  • --json [boolean] [default: false]

    return output as clean JSON

  • --deprecated-v1 [boolean] [default: false]

    Insert into a deprecated V1 Vectorize index. This must be enabled if the index was created with the V1 option.

vectorize upsert

Upsert vectors into a Vectorize index

wrangler vectorize upsert <name>

Positionals

  • name [string] [required]

    The name of the Vectorize index.

Options

  • --file [string] [required]

    A file containing line separated json (ndjson) vector objects.

  • --batch-size [number] [default: 5000]

    Number of vector records to include in a single upsert batch when sending to the Cloudflare API.

  • --json [boolean] [default: false]

    return output as clean JSON

vectorize query

Query a Vectorize index

wrangler vectorize query <name>

Positionals

  • name [string] [required]

    The name of the Vectorize index

Options

  • --vector [array] [required]

    Vector to query the Vectorize Index

  • --top-k [number] [default: 5]

    The number of results (nearest neighbors) to return

  • --return-values [boolean] [default: false]

    Specify if the vector values should be included in the results

  • --return-metadata [string] [choices: "all", "indexed", "none"] [default: "none"]

    Specify if the vector metadata should be included in the results

  • --namespace [string]

    Filter the query results based on this namespace

  • --filter [string]

    Filter the query results based on this metadata filter.

vectorize get-vectors

Get vectors from a Vectorize index

wrangler vectorize get-vectors <name>

Positionals

  • name [string] [required]

    The name of the Vectorize index.

Options

  • --ids [array] [required]

    Vector identifiers to be fetched from the Vectorize Index. Example: --ids a 'b' 1 '2'

vectorize delete-vectors

Delete vectors in a Vectorize index

wrangler vectorize delete-vectors <name>

Positionals

  • name [string] [required]

    The name of the Vectorize index.

Options

  • --ids [array] [required]

    Vector identifiers to be deleted from the Vectorize Index.
    Example: --ids a 'b' 1 '2'

vectorize create-metadata-index

Enable metadata filtering on the specified property

wrangler vectorize create-metadata-index <name>

Positionals

  • name [string] [required]

    The name of the Vectorize index.

  • property-name [string]

    The name of the metadata property to index.

  • type [string] [choices: "string", "number", "boolean"]

    The type of metadata property to index. Valid types are 'string', 'number' and 'boolean'.

vectorize list-metadata-index

List metadata properties on which metadata filtering is enabled

wrangler vectorize list-metadata-index <name>

Positionals

  • name [string] [required]

    The name of the Vectorize index.

Options

  • --json [boolean] [default: false]

    return output as clean JSON

vectorize delete-metadata-index

Delete metadata indexes

wrangler vectorize delete-metadata-index <name>

Positionals

  • name [string] [required]

    The name of the Vectorize index.

  • property-name [string]

    The name of the metadata property to index.


dev

đź‘‚ Start a local server for developing your Worker

wrangler dev [script]

Positionals

  • script [string]

    The path to an entry point for your worker

Options

  • --name [string]

    Name of the worker

  • --compatibility-date [string]

    Date to use for compatibility checks

  • --compatibility-flags, --compatibility-flag [array]

    Flags to use for compatibility checks

  • --latest [boolean] [default: true]

    Use the latest version of the worker runtime

  • --assets [string]

    Static assets to be served. Replaces Workers Sites.

  • --no-bundle [boolean] [default: false]

    Skip internal build steps and directly deploy script

  • --ip [string]

    IP address to listen on

  • --port [number]

    Port to listen on

  • --inspector-port [number]

    Port for devtools to connect to

  • --routes, --route [array]

    Routes to upload

  • --host [string]

    Host to forward requests to, defaults to the zone of project

  • --local-protocol [choices: "http", "https"]

    Protocol to listen to requests on, defaults to http.

  • --https-key-path [string]

    Path to a custom certificate key

  • --https-cert-path [string]

    Path to a custom certificate

  • --local-upstream [string]

    Host to act as origin in local mode, defaults to dev.host or route

  • --upstream-protocol [choices: "http", "https"]

    Protocol to forward requests to host on, defaults to https.

  • --var [array]

    A key-value pair to be injected into the script as a variable

  • --define [array]

    A key-value pair to be substituted in the script

  • --alias [array]

    A module pair to be substituted in the script

  • --jsx-factory [string]

    The function that is called for each JSX element

  • --jsx-fragment [string]

    The function that is called for each JSX fragment

  • --tsconfig [string]

    Path to a custom tsconfig.json file

  • -r, --remote [boolean] [default: false]

    Run on the global Cloudflare network with access to production resources

  • --minify [boolean]

    Minify the script

  • --node-compat [boolean]

    Enable Node.js compatibility

  • --persist-to [string]

    Specify directory to use for local persistence (defaults to .wrangler/state)

  • --live-reload [boolean]

    Auto reload HTML pages when change is detected in local mode

  • --test-scheduled [boolean] [default: false]

    Test scheduled events by visiting /__scheduled in browser

  • --log-level [choices: "debug", "info", "log", "warn", "error", "none"] [default: "log"]

    Specify logging level

  • --show-interactive-dev-session [boolean]

    Show interactive dev session
    (defaults to true if the terminal supports interactivity)

  • --experimental-dev-env, --x-dev-env [boolean] [default: true]

    Use the experimental DevEnv instantiation (unified across wrangler dev and unstable_dev)

  • --experimental-registry, --x-registry [boolean] [default: false]

    Use the experimental file based dev registry for multi-worker development

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 a Worker to Cloudflare

wrangler deploy [script]

Positionals

  • script [string]

    The path to an entry point for your worker

Options

  • --name [string]

    Name of the worker

  • --no-bundle [boolean] [default: false]

    Skip internal build steps and directly deploy Worker

  • --outdir [string]

    Output directory for the bundled worker

  • --compatibility-date [string]

    Date to use for compatibility checks

  • --compatibility-flags, --compatibility-flag [array]

    Flags to use for compatibility checks

  • --latest [boolean] [default: false]

    Use the latest version of the worker runtime

  • --assets [string]

    Static assets to be served. Replaces Workers Sites.

  • --var [array]

    A key-value pair to be injected into the script as a variable

  • --define [array]

    A key-value pair to be substituted in the script

  • --alias [array]

    A module pair to be substituted in the script

  • --triggers, --schedule, --schedules [array]

    cron schedules to attach

  • --routes, --route [array]

    Routes to upload

  • --jsx-factory [string]

    The function that is called for each JSX element

  • --jsx-fragment [string]

    The function that is called for each JSX fragment

  • --tsconfig [string]

    Path to a custom tsconfig.json file

  • --minify [boolean]

    Minify the Worker

  • --node-compat [boolean]

    Enable Node.js compatibility

  • --dry-run [boolean]

    Don't actually deploy

  • --upload-source-maps [boolean]

    Include source maps when uploading this worker.

  • --old-asset-ttl [number]

    Expire old assets in given seconds rather than immediate deletion.

  • --keep-vars [boolean] [default: false]

    Stop wrangler from deleting vars that are not present in the wrangler.toml
    By default Wrangler will remove all vars and replace them with those found in the wrangler.toml configuration.
    If your development approach is to modify vars after deployment via the dashboard you may wish to set this flag.

    --logpush
    Send Trace Events from this worker to Workers Logpush.
    This will not configure a corresponding Logpush job automatically.
    [boolean]
    --dispatch-namespace
    Name of a dispatch namespace to deploy the Worker to (Workers for Platforms)
    [string]


delete

đź—‘ Delete a Worker from Cloudflare

wrangler delete [script]

Positionals

  • script [string]

    The path to an entry point for your worker

Options

  • --name [string]

    Name of the worker

  • --dry-run [boolean]

    Don't actually delete

  • --force [boolean]

    Delete even if doing so will break other Workers that depend on this one

kv namespace

Manage Workers KV namespaces.

create

Create a new namespace.

wrangler kv namespace create <NAMESPACE> [OPTIONS]
  • NAMESPACE string required
    • The name of the new namespace.
  • --env string optional
    • Perform on a specific environment.
  • --preview boolean optional
    • Interact with a preview namespace (the preview_id value).

The following is an example of using the create command to create a KV namespace called MY_KV.

Terminal window
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.

Terminal window
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

List all KV namespaces associated with the current account ID.

wrangler kv namespace list

The following is an example that passes the Wrangler command through the jq command:

Terminal window
npx wrangler kv namespace list | jq "."
[
{
"id": "06779da6940b431db6e566b4846d64db",
"title": "TEST_NAMESPACE"
},
{
"id": "32ac1b3c2ed34ed3b397268817dea9ea",
"title": "STATIC_CONTENT"
}
]

delete

Delete a given namespace.

wrangler kv namespace delete {--binding=<BINDING>|--namespace-id=<NAMESPACE_ID>} [OPTIONS]
  • --binding string
    • The binding name of the namespace, as stored in the wrangler.toml file, to delete.
  • --namespace-id string
    • The ID of the namespace to delete.
  • --env string optional
    • Perform on a specific environment.
  • --preview boolean optional
    • Interact with a preview namespace instead of production.

The following is an example of deleting a KV namespace called MY_KV.

Terminal window
npx wrangler kv namespace delete --binding=MY_KV
Are you sure you want to delete namespace f7b02e7fc70443149ac906dd81ec1791? [y/n]
yes
Deleting namespace f7b02e7fc70443149ac906dd81ec1791
Deleted namespace f7b02e7fc70443149ac906dd81ec1791

The following is an example of deleting a preview KV namespace called MY_KV.

Terminal window
npx wrangler kv namespace delete --binding=MY_KV --preview
Are you sure you want to delete namespace 15137f8edf6c09742227e99b08aaf273? [y/n]
yes
Deleting namespace 15137f8edf6c09742227e99b08aaf273
Deleted namespace 15137f8edf6c09742227e99b08aaf273

kv key

Manage key-value pairs within a Workers KV namespace.

put

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]
  • KEY string required
    • The key to write to.
  • VALUE string optional
    • The value to write.
  • --path optional
    • When defined, the value is loaded from the file at --path rather than reading it from the VALUE argument. This is ideal for security-sensitive operations because it avoids saving keys and values into your terminal history.
  • --binding string
    • The binding name of the namespace, as stored in the wrangler.toml file, to delete.
  • --namespace-id string
    • The ID of the namespace to delete.
  • --env string optional
    • Perform on a specific environment.
  • --preview boolean optional
    • Interact with a preview namespace instead of production.
  • --ttl number optional
    • The lifetime (in number of seconds) that the key-value pair should exist before expiring. Must be at least 60 seconds. This option takes precedence over the expiration option.
  • --expiration number optional
    • The timestamp, in UNIX seconds, indicating when the key-value pair should expire.
  • --metadata string optional
    • Any (escaped) JSON serialized arbitrary object to a maximum of 1024 bytes.
  • --local boolean optional
    • Interact with locally persisted data.
  • --persist-to string 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.

Terminal window
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.

Terminal window
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.

Terminal window
npx wrangler kv key put --binding=MY_KV "my-key" "some-value" --ttl=10000
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.

Terminal window
npx wrangler kv key put --binding=MY_KV "my-key" --path=value.txt
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.

wrangler kv key list {--binding=<BINDING>|--namespace-id=<NAMESPACE_ID>} [OPTIONS]
  • --binding string
    • The binding name of the namespace, as stored in the wrangler.toml file, to delete.
  • --namespace-id string
    • The ID of the namespace to delete.
  • --env string optional
    • Perform on a specific environment.
  • --preview boolean optional
    • Interact with a preview namespace instead of production.
  • --prefix string optional
    • Only list keys that begin with the given prefix.
  • --local boolean optional
    • Interact with locally persisted data.
  • --persist-to string optional
    • Specify directory for locally persisted data.

Below is an example that passes the Wrangler command through the jq command:

Terminal window
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"
}
]

get

Read a single value by key from the given namespace.

wrangler kv key get <KEY> {--binding=<BINDING>|--namespace-id=<NAMESPACE_ID>} [OPTIONS]
  • KEY string required
    • The key value to get.
  • --binding string
    • The binding name of the namespace, as stored in the wrangler.toml file, to get from.
  • --namespace-id string
    • The ID of the namespace to get from.
  • --env string optional
    • Perform on a specific environment.
  • --preview boolean optional
    • Interact with a preview namespace instead of production.
  • --text boolean optional
    • Decode the returned value as a UTF-8 string.
  • --local boolean optional
    • Interact with locally persisted data.
  • --persist-to string 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.

Terminal window
npx wrangler kv key get --binding=MY_KV "my-key"
value

delete

Remove a single key value pair from the given namespace.

wrangler kv key delete <KEY> {--binding=<BINDING>|--namespace-id=<NAMESPACE_ID>} [OPTIONS]
  • KEY string required
    • The key value to get.
  • --binding string
    • The binding name of the namespace, as stored in the wrangler.toml file, to delete.
  • --namespace-id string
    • The ID of the namespace to delete.
  • --env string optional
    • Perform on a specific environment.
  • --preview boolean optional
    • Interact with a preview namespace instead of production.
  • --local boolean optional
    • Interact with locally persisted data.
  • --persist-to string 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.

Terminal window
npx wrangler kv key delete --binding=MY_KV "my-key"
Deleting the key "my-key" on namespace f7b02e7fc70443149ac906dd81ec1791.

kv bulk

Manage multiple key-value pairs within a Workers KV namespace in batches.

put

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]
  • FILENAME string required
    • The JSON file containing an array of key-value pairs to write to the namespace.
  • --binding string
    • The binding name of the namespace, as stored in the wrangler.toml file, to delete.
  • --namespace-id string
    • The ID of the namespace to delete.
  • --env string optional
    • Perform on a specific environment.
  • --preview boolean optional
    • Interact with a preview namespace instead of production.
  • --local boolean optional
    • Interact with locally persisted data.
  • --persist-to string 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:

  • key string required
    • The key’s name. The name may be 512 bytes maximum. All printable, non-whitespace characters are valid.
  • value string required
    • The UTF-8 encoded string to be stored, up to 25 MB in length.
  • metadata object optional
    • Any arbitrary object (must serialize to JSON) to a maximum of 1,024 bytes.
  • expiration number optional
    • The time, measured in number of seconds since the UNIX epoch, at which the key should expire.
  • expiration_ttl number optional
    • The number of seconds the document should exist before expiring. Must be at least 60 seconds.
  • base64 boolean 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.

The following is an example of writing all the key-value pairs found in the allthethingsupload.json file.

Terminal window
npx wrangler kv bulk put --binding=MY_KV allthethingsupload.json
Success!

delete

Delete all keys read from a JSON file within a given namespace.

wrangler kv bulk delete <FILENAME> {--binding=<BINDING>|--namespace-id=<NAMESPACE_ID>} [OPTIONS]
  • FILENAME string required
    • The JSON file containing an array of keys to delete from the namespace.
  • --binding string
    • The binding name of the namespace, as stored in the wrangler.toml file, to delete.
  • --namespace-id string
    • The ID of the namespace to delete.
  • --env string optional
    • Perform on a specific environment.
  • --preview boolean optional
    • Interact with a preview namespace instead of production.
  • --local boolean optional
    • Interact with locally persisted data.
  • --persist-to string 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.

Terminal window
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!

r2 bucket

Interact with buckets in an R2 store.

r2 bucket create

Create a new R2 bucket

wrangler r2 bucket create <name>

Positionals

  • name [string] [required]

    The name of the new bucket

Options

  • -J, --jurisdiction [string]

    The jurisdiction where the new bucket will be created

  • -s, --storage-class [string]

    The default storage class for objects uploaded to this bucket

r2 bucket delete

Delete an R2 bucket

wrangler r2 bucket delete <name>

Positionals

  • name [string] [required]

    The name of the bucket to delete

Options

  • -J, --jurisdiction [string]

    The jurisdiction where the bucket exists

r2 bucket list

List R2 buckets

wrangler r2 bucket list

Options

  • -J, --jurisdiction [string]

    The jurisdiction to list

r2 bucket notification create

Create an event notification rule for an R2 bucket

wrangler r2 bucket notification create <bucket>

Positionals

  • bucket [string] [required]

    The name of the R2 bucket to create an event notification rule for

Options

  • --event-types, --event-type [array] [required] [choices: "object-create", "object-delete"]

    The type of event(s) that will emit event notifications

  • --prefix [string]

    The prefix that an object must match to emit event notifications (note: regular expressions not supported)

  • --suffix [string]

    The suffix that an object must match to emit event notifications (note: regular expressions not supported)

  • --queue [string] [required]

    The name of the queue that will receive event notification messages

r2 bucket notification delete

Delete an event notification rule from an R2 bucket

wrangler r2 bucket notification delete <bucket>

Positionals

  • bucket [string] [required]

    The name of the R2 bucket to delete an event notification rule for

Options

  • --queue [string] [required]

    The name of the queue that corresponds to the event notification rule. If no rule is provided, all event notification rules associated with the bucket and queue will be deleted

  • --rule [string]

    The ID of the event notification rule to delete

r2 bucket notification list

List event notification rules for a bucket

wrangler r2 bucket notification list <bucket>

Positionals

  • bucket [string] [required]

    The name of the R2 bucket to get event notification rules for

r2 bucket sippy enable

Enable Sippy on an R2 bucket

wrangler r2 bucket sippy enable <name>

Positionals

  • name [string] [required]

    The name of the bucket

Options

  • -J, --jurisdiction [string]

    The jurisdiction where the bucket exists

  • --provider [choices: "AWS", "GCS"]
  • --bucket [string]

    The name of the upstream bucket

  • --region [string]

    (AWS provider only) The region of the upstream bucket

  • --access-key-id [string]

    (AWS provider only) The secret access key id for the upstream bucket

  • --secret-access-key [string]

    (AWS provider only) The secret access key for the upstream bucket

  • --service-account-key-file [string]

    (GCS provider only) The path to your Google Cloud service account key JSON file

  • --client-email [string]

    (GCS provider only) The client email for your Google Cloud service account key

  • --private-key [string]

    (GCS provider only) The private key for your Google Cloud service account key

  • --r2-access-key-id [string]

    The secret access key id for this R2 bucket

  • --r2-secret-access-key [string]

    The secret access key for this R2 bucket

r2 bucket sippy disable

Disable Sippy on an R2 bucket

wrangler r2 bucket sippy disable <name>

Positionals

  • name [string] [required]

    The name of the bucket

Options

  • -J, --jurisdiction [string]

    The jurisdiction where the bucket exists

r2 bucket sippy get

Check the status of Sippy on an R2 bucket

wrangler r2 bucket sippy get <name>

Positionals

  • name [string] [required]

    The name of the bucket

Options

  • -J, --jurisdiction [string]

    The jurisdiction where the bucket exists


r2 object

Interact with R2 objects.

r2 object get

Fetch an object from an R2 bucket

wrangler r2 object get <objectPath>

Positionals

  • objectPath [string] [required]

    The source object path in the form of {bucket}/{key}

Options

  • -f, --file [string]

    The destination file to create

  • -p, --pipe [boolean]

    Enables the file to be piped to a destination, rather than specified with the --file option

  • --local [boolean]

    Interact with local storage

  • --persist-to [string]

    Directory for local persistence

  • -J, --jurisdiction [string]

    The jurisdiction where the object exists

r2 object put

Create an object in an R2 bucket

wrangler r2 object put <objectPath>

Positionals

  • objectPath [string] [required]

    The destination object path in the form of {bucket}/{key}

Options

  • -f, --file [string]

    The path of the file to upload

  • -p, --pipe [boolean]

    Enables the file to be piped in, rather than specified with the --file option

  • --content-type, --ct [string]

    A standard MIME type describing the format of the object data

  • --content-disposition, --cd [string]

    Specifies presentational information for the object

  • --content-encoding, --ce [string]

    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-Type header field

  • --content-language, --cl [string]

    The language the content is in

  • --cache-control, --cc [string]

    Specifies caching behavior along the request/reply chain

  • -e, --expires [string]

    The date and time at which the object is no longer cacheable

  • --local [boolean]

    Interact with local storage

  • --persist-to [string]

    Directory for local persistence

  • -J, --jurisdiction [string]

    The jurisdiction where the object will be created

  • -s, --storage-class [string]

    The storage class of the object to be created

r2 object delete

Delete an object in an R2 bucket

wrangler r2 object delete <objectPath>

Positionals

  • objectPath [string] [required]

    The destination object path in the form of {bucket}/{key}

Options

  • --local [boolean]

    Interact with local storage

  • --persist-to [string]

    Directory for local persistence

  • -J, --jurisdiction [string]

    The jurisdiction where the object exists


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.

secret put

Create or update a secret variable for a Worker

wrangler secret put <key>

Positionals

  • key [string] [required]

    The variable name to be accessible in the Worker

Options

  • --name [string]

    Name of the Worker

When running this command, you will be prompted to input the secret’s value:

Terminal window
npx wrangler secret put FOO
? Enter a secret value: › ***
🌀 Creating the secret for script worker-app
✨ Success! Uploaded secret FOO

The put command can also receive piped input. For example:

Terminal window
echo "-----BEGIN PRIVATE KEY-----\nM...==\n-----END PRIVATE KEY-----\n" | wrangler secret put PRIVATE_KEY

secret delete

Delete a secret variable from a Worker

wrangler secret delete <key>

Positionals

  • key [string] [required]

    The variable name to be accessible in the Worker

Options

  • --name [string]

    Name of the Worker

secret list

List all secrets for a Worker

wrangler secret list

Options

  • --name [string]

    Name of the Worker

  • --format [choices: "json", "pretty"] [default: "json"]

    The format to print the secrets in

The following is an example of listing the secrets for the current Worker.

Terminal window
npx wrangler secret list
[
{
"name": "FOO",
"type": "secret_text"
}
]

secret bulk

Bulk upload secrets for a Worker

wrangler secret bulk [json]

Positionals

  • json [string]

    The JSON file of key-value pairs to upload, in form {"key": value, ...}

Options

  • --name [string]

    Name of the Worker

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"
}
Terminal window
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 upload

tail

🦚 Start a log tailing session for a Worker

wrangler tail [worker]

Positionals

  • worker [string]

    Name or route of the worker to tail

Options

  • --format [choices: "json", "pretty"] [default: "json"]

    The format of log entries

  • --status [array] [choices: "ok", "error", "canceled"]

    Filter by invocation status

  • --header [string]

    Filter by HTTP header

  • --method [array]

    Filter by HTTP method

  • --sampling-rate [number]

    Adds a percentage of requests to log sampling rate

  • --search [string]

    Filter by a text match in console.log messages

  • --ip [array]

    Filter by the IP address the request originates from. Use "self" to filter for your own IP

  • --version-id [string]

    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 ↗.


pages

Configure Cloudflare Pages.

pages dev

Develop your full-stack Pages application locally

wrangler pages dev [directory] [-- command..]

Positionals

  • directory [string]

    The directory of static assets to serve

  • command [deprecated]

    The proxy command to run

Options

  • --compatibility-date [string]

    Date to use for compatibility checks

  • --compatibility-flags, --compatibility-flag [array]

    Flags to use for compatibility checks

  • --ip [string]

    The IP address to listen on

  • --port [number]

    The port to listen on (serve from)

  • --inspector-port [number]

    Port for devtools to connect to

  • --proxy [deprecated] [number]

    The port to proxy (where the static assets are served)

  • --script-path [default: _worker.js]

    The location of the single Worker script if not using functions

    [deprecated] [string]

  • --no-bundle [boolean] [default: false]

    Whether to run bundling on _worker.js

  • -b, --binding [array]

    Bind variable/secret (KEY=VALUE)

  • -k, --kv [array]

    KV namespace to bind (--kv KV_BINDING)

  • --d1 [array]

    D1 database to bind (--d1 D1_BINDING)

  • -o, --do [array]

    Durable Object to bind (--do DO_BINDING=CLASS_NAME@SCRIPT_NAME)

  • --r2 [array]

    R2 bucket to bind (--r2 R2_BINDING)

  • --ai [string]

    AI to bind (--ai AI_BINDING)

  • --version-metadata [string]

    Worker Version metadata (--version-metadata VERSION_METADATA_BINDING)

  • --service [array]

    Service to bind (--service SERVICE=SCRIPT_NAME)

  • --live-reload [boolean] [default: false]

    Auto reload HTML pages when change is detected

  • --local-protocol [choices: "http", "https"]

    Protocol to listen to requests on, defaults to http.

  • --https-key-path [string]

    Path to a custom certificate key

  • --https-cert-path [string]

    Path to a custom certificate

  • --persist-to [string]

    Specify directory to use for local persistence (defaults to .wrangler/state)

  • --log-level [choices: "debug", "info", "log", "warn", "error", "none"]

    Specify logging level

  • --show-interactive-dev-session [boolean]

    Show interactive dev session (defaults to true if the terminal supports interactivity)

  • --experimental-dev-env, --x-dev-env [boolean] [default: false]

    Use the experimental DevEnv instantiation (unified across wrangler dev and unstable_dev)

  • --experimental-registry, --x-registry [boolean] [default: false]

    Use the experimental file based dev registry for multi-worker development

pages download config

Experimental: Download your Pages project config as a wrangler.toml file

wrangler pages download config [projectName]

Positionals

  • projectName [string]

    The Pages project to download

Options

  • --force [boolean]

    Overwrite an existing wrangler.toml file without prompting

pages project list

List your Cloudflare Pages projects

wrangler pages project list

pages project create

Create a new Cloudflare Pages project

wrangler pages project create [project-name]

Positionals

  • project-name [string]

    The name of your Pages project

Options

  • --production-branch [string]

    The name of the production branch of your project

  • --compatibility-flags, --compatibility-flag [array]

    Flags to use for compatibility checks

  • --compatibility-date [string]

    Date to use for compatibility checks

pages project delete

Delete a Cloudflare Pages project

wrangler pages project delete [project-name]

Positionals

  • project-name [string] [required]

    The name of your Pages project

Options

  • -y, --yes [boolean]

    Answer "yes" to confirm project deletion

pages deployment list

List deployments in your Cloudflare Pages project

wrangler pages deployment list

Options

  • --project-name [string]

    The name of the project you would like to list deployments for

pages deployment tail

Start a tailing session for a project's deployment and livestream logs from your Functions

wrangler pages deployment tail [deployment]

Positionals

  • deployment [string]

    (Optional) ID or URL of the deployment to tail. Specify by environment if deployment ID is unknown.

Options

  • --project-name [string]

    The name of the project you would like to tail

  • --environment [string] [choices: "production", "preview"] [default: "production"]

    When not providing a specific deployment ID, specifying environment will grab the latest production or preview deployment

  • --format [choices: "json", "pretty"] [default: "json"]

    The format of log entries

  • --status [array] [choices: "ok", "error", "canceled"]

    Filter by invocation status

  • --header [string]

    Filter by HTTP header

  • --method [array]

    Filter by HTTP method

  • --search [string]

    Filter by a text match in console.log messages

  • --sampling-rate [number]

    Adds a percentage of requests to log sampling rate

  • --ip [array]

    Filter by the IP address the request originates from. Use "self" to filter for your own IP

After starting wrangler pages deployment tail, you will receive a live stream of console and exception logs for each request your Functions receive.

pages deploy

Deploy a directory of static assets as a Pages deployment

wrangler pages deploy [directory]

Positionals

  • directory [string]

    The directory of static files to upload

Options

  • --project-name [string]

    The name of the project you want to deploy to

  • --branch [string]

    The name of the branch you want to deploy to

  • --commit-hash [string]

    The SHA to attach to this deployment

  • --commit-message [string]

    The commit message to attach to this deployment

  • --commit-dirty [boolean]

    Whether or not the workspace should be considered dirty for this deployment

  • --skip-caching [boolean]

    Skip asset caching which speeds up builds

  • --no-bundle [boolean] [default: false]

    Whether to run bundling on _worker.js before deploying

  • --upload-source-maps [boolean] [default: false]

    Whether to upload any server-side sourcemaps with this deployment

pages secret put

Create or update a secret variable for a Pages project

wrangler pages secret put <key>

Positionals

  • key [string] [required]

    The variable name to be accessible in the Pages project

Options

  • --project-name, --project [string]

    The name of your Pages project

pages secret delete

Delete a secret variable from a Pages project

wrangler pages secret delete <key>

Positionals

  • key [string] [required]

    The variable name to be accessible in the Pages project

Options

  • --project-name, --project [string]

    The name of your Pages project

pages secret list

List all secrets for a Pages project

wrangler pages secret list

Options

  • --project-name, --project [string]

    The name of your Pages project

pages secret bulk

Bulk upload secrets for a Pages project

wrangler pages secret bulk [json]

Positionals

  • json [string]

    The JSON file of key-value pairs to upload, in form {"key": value, ...}

Options

  • --project-name, --project [string]

    The name of your Pages project


queues

Manage your Workers Queues configurations.

queues create

Create a Queue

wrangler queues create <name>

Positionals

  • name [string] [required]

    The name of the queue

Options

  • --delivery-delay-secs [number]

    How long a published message should be delayed for, in seconds. Must be a positive integer

queues delete

Delete a Queue

wrangler queues delete <name>

Positionals

  • name [string] [required]

    The name of the queue

queues list

List Queues

wrangler queues list

Options

  • --page [number]

    Page number for pagination

queues consumer add

Add a Queue Worker Consumer

wrangler queues consumer add <queue-name> <script-name>

Positionals

  • queue-name [string] [required]

    Name of the queue to configure

  • script-name [string] [required]

    Name of the consumer script

Options

  • --batch-size [number]

    Maximum number of messages per batch

  • --batch-timeout [number]

    Maximum number of seconds to wait to fill a batch with messages

  • --message-retries [number]

    Maximum number of retries for each message

  • --dead-letter-queue [string]

    Queue to send messages that failed to be consumed

  • --max-concurrency [number]

    The maximum number of concurrent consumer Worker invocations. Must be a positive integer

  • --retry-delay-secs [number]

    The number of seconds to wait before retrying a message

queues consumer remove

Remove a Queue Worker Consumer

wrangler queues consumer remove <queue-name> <script-name>

Positionals

  • queue-name [string] [required]

    Name of the queue to configure

  • script-name [string] [required]

    Name of the consumer script


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.

login

🔓 Login to Cloudflare

wrangler login

Options

  • --scopes-list unknown

    List all the available OAuth scopes with descriptions

  • --browser [boolean] [default: true]

    Automatically open the OAuth link in a browser

  • --scopes [array]

    Pick the set of applicable OAuth scopes when logging in

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:

Terminal window
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:

Terminal window
curl <LOCALHOST_URL>

logout

🚪 Logout from Cloudflare

wrangler logout

If you are using CLOUDFLARE_API_TOKEN instead of OAuth, and you can logout by deleting your API token in the Cloudflare dashboard:

  1. Log in to the Cloudflare dashboard ↗.
  2. Go to My Profile > API Tokens.
  3. Select the three-dot menu on your Wrangler token.
  4. Select Delete.

whoami

🕵️ Retrieve your user information

wrangler whoami

Options

  • --account [string]

    Show membership information for the given account (id or name).


versions

versions upload

Uploads your Worker code and config as a new Version [beta]

wrangler versions upload

Positionals

  • script [string]

    The path to an entry point for your worker

Options

  • --name [string]

    Name of the worker

  • --no-bundle [boolean] [default: false]

    Skip internal build steps and directly deploy Worker

  • --outdir [string]

    Output directory for the bundled worker

  • --compatibility-date [string]

    Date to use for compatibility checks

  • --compatibility-flags, --compatibility-flag [array]

    Flags to use for compatibility checks

  • --latest [boolean] [default: false]

    Use the latest version of the worker runtime

  • --assets [string]

    Static assets to be served. Replaces Workers Sites.

  • --var [array]

    A key-value pair to be injected into the script as a variable

  • --define [array]

    A key-value pair to be substituted in the script

  • --alias [array]

    A module pair to be substituted in the script

  • --jsx-factory [string]

    The function that is called for each JSX element

  • --jsx-fragment [string]

    The function that is called for each JSX fragment

  • --tsconfig [string]

    Path to a custom tsconfig.json file

  • --minify [boolean]

    Minify the Worker

  • --upload-source-maps [boolean]

    Include source maps when uploading this Worker Gradual Rollouts Version.

  • --node-compat [boolean]

    Enable Node.js compatibility

  • --dry-run [boolean]

    Don't actually deploy

  • --tag [string]

    A tag for this Worker Gradual Rollouts Version

  • --message [string]

    A descriptive message for this Worker Gradual Rollouts Version

versions deploy

Safely roll out new Versions of your Worker by splitting traffic between multiple Versions [beta]

wrangler versions deploy [version-specs..]

Positionals

  • version-specs [array] [default: []]

    Shorthand notation to deploy Worker Version(s) [<version-id>@<percentage>..]

Options

  • --name [string]

    Name of the worker

  • --version-id [array]

    Worker Version ID(s) to deploy

  • --percentage [number]

    Percentage of traffic to split between Worker Version(s) (0-100)

  • --message [string]

    Description of this deployment (optional)

  • -y, --yes [boolean] [default: false]

    Automatically accept defaults to prompts

  • --dry-run [boolean] [default: false]

    Don't actually deploy

versions list

List the 10 most recent Versions of your Worker [beta]

wrangler versions list

Options

  • --name [string]

    Name of the worker

  • --json [boolean] [default: false]

    Display output as clean JSON

versions secret put

Create or update a secret variable for a Worker

wrangler versions secret put <key>

Positionals

  • key [string] [required]

    The variable name to be accessible in the Worker

Options

  • --name [string]

    Name of the Worker

  • --message [string]

    Description of this deployment

  • --tag [string]

    A tag for this version

versions secret delete

Delete a secret variable from a Worker

wrangler versions secret delete <key>

Positionals

  • key [string] [required]

    The variable name to be accessible in the Worker

Options

  • --name [string]

    Name of the Worker

  • --message [string]

    Description of this deployment

  • --tag [string]

    A tag for this version

versions secret bulk

Create or update a secret variable for a Worker

wrangler versions secret bulk [json]

Positionals

  • json [string]

    The JSON file of key-value pairs to upload, in form {"key": value, ...}

Options

  • --name [string]

    Name of the Worker

  • --message [string]

    Description of this deployment

  • --tag [string]

    A tag for this version


triggers

triggers deploy

Updates the triggers of your current deployment [beta]

wrangler triggers deploy

Options

  • --name [string]

    Name of the worker

  • --triggers, --schedule, --schedules [array]

    cron schedules to attach

  • --routes, --route [array]

    Routes to upload

  • --dry-run [boolean]

    Don't actually deploy


deployments

Deployments track the version(s) of your Worker that are actively serving traffic.

deployments list

Displays the 10 most recent deployments of your Worker

wrangler deployments list

Options

  • --name [string]

    Name of the worker

  • --json [boolean] [default: false]

    Display output as clean JSON

deployments status

View the current state of your production

wrangler deployments status

Options

  • --name [string]

    Name of the worker

  • --json [boolean] [default: false]

    Display output as clean JSON

rollback

đź”™ Rollback a deployment for a Worker

wrangler rollback [version-id]

Positionals

  • version-id [string]

    The ID of the Worker Version to rollback to

Options

  • --name [string]

    The name of your worker

  • -m, --message [string]

    The reason for this rollback

  • -y, --yes [boolean] [default: false]

    Automatically accept defaults to prompts


dispatch namespace

dispatch-namespace list

List all dispatch namespaces

wrangler dispatch-namespace list

dispatch-namespace get

Get information about a dispatch namespace

wrangler dispatch-namespace get <name>

Positionals

  • name [string] [required]

    Name of the dispatch namespace

dispatch-namespace create

Create a dispatch namespace

wrangler dispatch-namespace create <name>

Positionals

  • name [string] [required]

    Name of the dispatch namespace

dispatch-namespace delete

Delete a dispatch namespace

wrangler dispatch-namespace delete <name>

Positionals

  • name [string] [required]

    Name of the dispatch namespace

dispatch-namespace rename

Rename a dispatch namespace

wrangler dispatch-namespace rename <old-name> <new-name>

Positionals

  • old-name [string] [required]

    Name of the dispatch namespace

  • new-name [string] [required]

    New name of the dispatch namespace


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).

mtls-certificate upload

Upload an mTLS certificate

wrangler mtls-certificate upload

Options

  • --cert [string] [required]

    The path to a certificate file (.pem) containing a chain of certificates to upload

  • --key [string] [required]

    The path to a file containing the private key for your leaf certificate

  • --name [string]

    The name for the certificate

The following is an example of using the upload command to upload an mTLS certificate.

Terminal window
npx wrangler mtls-certificate upload --cert cert.pem --key key.pem --name my-origin-cert
Uploading mTLS Certificate my-origin-cert...
Success! Uploaded mTLS Certificate my-origin-cert
ID: 99f5fef1-6cc1-46b8-bd79-44a0d5082b8d
Issuer: CN=my-secured-origin.com,OU=my-team,O=my-org,L=San Francisco,ST=California,C=US
Expires: 1/01/2025

You 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.

mtls-certificate list

List uploaded mTLS certificates

wrangler mtls-certificate list

The following is an example of using the list command to upload an mTLS certificate.

Terminal window
npx wrangler mtls-certificate list
ID: 99f5fef1-6cc1-46b8-bd79-44a0d5082b8d
Name: my-origin-cert
Issuer: CN=my-secured-origin.com,OU=my-team,O=my-org,L=San Francisco,ST=California,C=US
Created on: 1/01/2023
Expires: 1/01/2025
ID: c5d004d1-8312-402c-b8ed-6194328d5cbe
Issuer: CN=another-origin.com,OU=my-team,O=my-org,L=San Francisco,ST=California,C=US
Created on: 1/01/2023
Expires: 1/01/2025

mtls-certificate delete

Delete an mTLS certificate

wrangler mtls-certificate delete

Options

  • --id [string]

    The id of the mTLS certificate to delete

  • --name [string]

    The name of the mTLS certificate record to delete

The following is an example of using the delete command to delete an mTLS certificate.

Terminal window
npx wrangler mtls-certificate delete --id 99f5fef1-6cc1-46b8-bd79-44a0d5082b8d
Are you sure you want to delete certificate 99f5fef1-6cc1-46b8-bd79-44a0d5082b8d (my-origin-cert)? [y/n]
yes
Deleting certificate 99f5fef1-6cc1-46b8-bd79-44a0d5082b8d...
Deleted certificate 99f5fef1-6cc1-46b8-bd79-44a0d5082b8d successfully

types

📝 Generate types from bindings and module rules in configuration

wrangler types [path]

Positionals

  • path [string] [default: "worker-configuration.d.ts"]

    The path to the declaration file to generate

Options

  • --env-interface [string] [default: "Env"]

    The name of the generated environment interface

  • --experimental-include-runtime, --x-include-runtime [string]

    The path of the generated runtime types file