General commands
Learn about general Wrangler commands for developing, deploying, and managing Workers and other pieces of the Cloudflare developer platform.
Open the Cloudflare developer documentation in your default browser.
npx wrangler docs [SEARCH]pnpm wrangler docs [SEARCH]yarn wrangler docs [SEARCH]-
[SEARCH]stringEnter search terms (e.g. the wrangler command) you want to know more about
-
--yesboolean alias: --yTakes you to the docs, even if search fails
Global flags
-
--vboolean alias: --versionShow version number
-
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
-
--configstring alias: --cPath to Wrangler configuration file
-
--envstring alias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
-
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
-
--experimental-provisionboolean aliases: --x-provision default: trueExperimental: Enable automatic resource provisioning
-
--experimental-auto-createboolean alias: --x-auto-create default: trueAutomatically provision draft bindings with new resources
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 generated Wrangler configuration.
- The name of the Workers project. This is both the directory name and
--yesboolean optional- Answer yes to any prompts for new projects.
--from-dashstring optional- Fetch a Worker initialized from the dashboard. This is done by passing the flag and the Worker name.
wrangler init --from-dash <WORKER_NAME>. - The
--from-dashcommand will not automatically sync changes made to the dashboard after the command is used. Therefore, it is recommended that you continue using the CLI.
- Fetch a Worker initialized from the dashboard. This is done by passing the flag and the Worker name.
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
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 configuration file does not include a
mainkey (for example,main = "index.js").
- The path to an entry point for your Worker. Only required if your Wrangler configuration file does not include a
--namestring optional- Name of the Worker.
--config,-cstring[] optional- Path(s) to Wrangler configuration file. If not provided, Wrangler will use the nearest config file based on your current working directory.
- You can provide multiple configuration files to run multiple Workers in one dev session like this:
wrangler dev -c ./wrangler.toml -c ../other-worker/wrangler.toml. The first config will be treated as the primary Worker, which will be exposed over HTTP. The remaining config files will only be accessible via a service binding from the primary Worker.
--no-bundleboolean (default: false) optional- Skip Wrangler's build steps. Particularly useful when using custom builds. Refer to Bundling ↗ for more information.
--envstring optional- Perform on a specific environment.
--compatibility-datestring optional- A date in the form yyyy-mm-dd, which will be used to determine which version of the Workers runtime is used.
--compatibility-flags,--compatibility-flagstring[] optional- Flags to use for compatibility checks.
--latestboolean (default: true) optional- Use the latest version of the Workers runtime.
--ipstring optional- IP address to listen on, defaults to
localhost.
- IP address to listen on, defaults to
--portnumber optional- Port to listen on.
--inspector-portnumber optional- Port for devtools to connect to.
--routes,--routestring[] optional- Routes to upload.
- For example:
--route example.com/*.
--hoststring optional- Host to forward requests to, defaults to the zone of project.
--local-protocol'http'|'https' (default: http) optional- Protocol to listen to requests on.
--https-key-pathstring optional- Path to a custom certificate key.
--https-cert-pathstring optional- Path to a custom certificate.
--local-upstreamstring optional- Host to act as origin in local mode, defaults to
dev.hostor route.
- Host to act as origin in local mode, defaults to
--assetsstring optional beta- Folder of static assets to be served. Replaces Workers Sites. Visit assets for more information.
--sitestring optional deprecated, use `--assets`- Folder of static assets for Workers Sites.
--site-includestring[] optional deprecated- Array of
.gitignore-style patterns that match file or directory names from the sites directory. Only matched items will be uploaded.
- Array of
--site-excludestring[] optional deprecated- Array of
.gitignore-style patterns that match file or directory names from the sites directory. Matched items will not be uploaded.
- Array of
--upstream-protocol'http'|'https' (default: https) optional- Protocol to forward requests to host on.
--varkey:value\[] optional- Array of
key:valuepairs to inject as variables into your code. The value will always be passed as a string to your Worker. - For example,
--var "git_hash:'$(git rev-parse HEAD)'" "test:123"makes thegit_hashandtestvariables available in your Worker'senv. - This flag is an alternative to defining
varsin your Wrangler configuration file. If defined in both places, this flag's values will be used.
- Array of
--definekey:value\[] optional- Array of
key:valuepairs to replace global identifiers in your code. - For example,
--define "GIT_HASH:'$(git rev-parse HEAD)'"will replace all uses ofGIT_HASHwith the actual value at build time. - This flag is an alternative to defining
definein your Wrangler configuration file. If defined in both places, this flag's values will be used.
- Array of
--tsconfigstring optional- Path to a custom
tsconfig.jsonfile.
- Path to a custom
--minifyboolean optional- Minify the Worker.
--persist-tostring optional- Specify directory to use for local persistence.
--remoteboolean (default: false) optional- Develop against remote resources and data stored on Cloudflare's network.
--test-scheduledboolean (default: false) optional- Exposes a
/__scheduledfetch route which will trigger a scheduled event (Cron Trigger) for testing during development. To simulate different cron patterns, acronquery parameter can be passed in:/__scheduled?cron=*+*+*+*+*or/cdn-cgi/handler/scheduled?cron=*+*+*+*+*.
- Exposes a
--log-level'debug'|'info'|'log'|'warn'|'error|'none' (default: log) optional- Specify Wrangler's logging level.
--show-interactive-dev-sessionboolean (default: true if the terminal supports interactivity) optional- Show the interactive dev session.
--aliasArray<string>- Specify modules to alias using module aliasing.
--typesboolean (default: false) optional- Generate types from your Worker configuration.
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
wrangler dev is a way to locally test your Worker while developing. With wrangler dev running, send HTTP requests to localhost:8787 and your Worker should execute as expected. You will also see console.log messages and exceptions appearing in your terminal.
Deploy your Worker to Cloudflare.
When you run wrangler deploy in a project directory without a Wrangler configuration file, Wrangler will automatically detect your framework and configure your project for Cloudflare Workers. This command will prompt you to confirm the detected settings before applying changes. Confirm that you would like to proceed, and your project will be configured and deployed.
To configure your project without deploying, use wrangler setup instead.
wrangler deploy [<PATH>] [OPTIONS]-
PATHstring- A path specific what needs to be deployed, this can either be:
-
The path to an entry point for your Worker.
- Only required if your Wrangler configuration file does not include a
mainkey (for example,main = "index.js").
- Only required if your Wrangler configuration file does not include a
-
Or the path to an assets directory for the deployment of a static site.
- Visit assets for more information.
- This overrides the eventual
assetsconfiguration in your Wrangler configuration file. - This is equivalent to the
--assetsoption listed below. - Note: this option currently only works only in interactive mode (so not in CI systems).
-
- A path specific what needs to be deployed, this can either be:
-
--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.
-
--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 your Wrangler configuration file. If defined in both places, this flag's values will be used.
- Array of
-
--definekey:value\[] optional- Array of
key:valuepairs to replace global identifiers in your code. - For example,
--define GIT_HASH:$(git rev-parse HEAD)will replace all uses ofGIT_HASHwith the actual value at build time. - This flag is an alternative to defining
definein your Wrangler configuration file. If defined in both places, this flag's values will be used.
- Array of
-
--triggers,--schedule,--schedulesstring[] optional- Cron schedules to attach to the deployed Worker. Refer to Cron Trigger Examples.
-
--routes,--routestring[] optional- Routes where this Worker will be deployed.
- For example:
--route example.com/*.
-
--tsconfigstring optional- Path to a custom
tsconfig.jsonfile.
- Path to a custom
-
--minifyboolean optional- Minify the bundled Worker before deploying.
-
--dry-runboolean (default: false) optional- Compile a project without actually deploying to live servers. Combined with
--outdir, this is also useful for testing the output ofnpx wrangler deploy. It also gives developers a chance to upload our generated sourcemap to a service like Sentry, so that errors from the Worker can be mapped against source code, but before the service goes live.
- Compile a project without actually deploying to live servers. Combined with
-
--keep-varsboolean (default: false) optional- It is recommended best practice to treat your Wrangler developer environment as a source of truth for your Worker configuration, and avoid making changes via the Cloudflare dashboard.
- If you change your environment variables in the Cloudflare dashboard, Wrangler will override them the next time you deploy. If you want to disable this behaviour set
keep-varstotrue. - Secrets are never deleted by a deployment whether this flag is true or false.
-
--dispatch-namespacestring optional- Specify the Workers for Platforms dispatch namespace to upload this Worker to.
-
--metafilestring optional- Specify a file to write the build metadata from esbuild to. If flag is used without a path string, this defaults to
bundle-meta.jsoninside the directory specified by--outdir. This can be useful for understanding the bundle size.
- Specify a file to write the build metadata from esbuild to. If flag is used without a path string, this defaults to
-
--containers-rolloutimmediate | gradual optional- Specify the rollout strategy for Containers associated with the Worker. If set to
immediate, 100% of container instances will be updated in one rollout step, overriding any configuration inrollout_step_percentage. Note thatrollout_active_grace_period, if configured, still applies. - Defaults to
gradual, where the default rollout is 10% then 100% of instances.
- Specify the rollout strategy for Containers associated with the Worker. If set to
-
--strictboolean (default: false) optional- Turns on strict mode for the deployment command, meaning that the command will be more defensive and prevent deployments which could introduce potential issues. In particular, this mode prevents deployments if the deployment would potentially override remote settings in non-interactive environments.
-
--tagstring optional- A tag for this Worker version. Matches the behavior of
wrangler versions upload --tag.
- A tag for this Worker version. Matches the behavior of
-
--messagestring optional- A descriptive message for this Worker version and deployment. Matches the behavior of
wrangler versions upload --message. The message is also applied to the deployment.
- A descriptive message for this Worker version and deployment. Matches the behavior of
-
--yesboolean (default: false) optional- Skip confirmation prompts and run automatic project configuration non-interactively using detected settings. Only applicable when no Wrangler configuration file exists in your project.
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
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 configuration file does not include a
mainkey (for example,main = "index.js").
- The path to an entry point for your Worker. Only required if your Wrangler configuration file does not include a
--namestring optional- Name of the Worker.
--envstring optional- Perform on a specific environment.
--dry-runboolean (default: false) optional- Do not actually delete the Worker. This is useful for testing the output of
wrangler delete.
- Do not actually delete the Worker. This is useful for testing the output of
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
Experimental
🪄 Setup a project to work on Cloudflare
npx wrangler setuppnpm wrangler setupyarn wrangler setup-
--yesboolean alias: --y default: falseAnswer "yes" to any prompts for configuring your project
-
--buildboolean default: falseRun your project's build command once it has been configured
-
--dry-runbooleanRuns the command without applying any filesystem modifications
Global flags
-
--vboolean alias: --versionShow version number
-
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
-
--configstring alias: --cPath to Wrangler configuration file
-
--envstring alias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
-
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
-
--experimental-provisionboolean aliases: --x-provision default: trueExperimental: Enable automatic resource provisioning
-
--experimental-auto-createboolean alias: --x-auto-create default: trueAutomatically provision draft bindings with new resources
This command configures your project for Cloudflare Workers without deploying. It performs the same automatic project configuration as wrangler deploy, but does not deploy. This is useful when you want to review the generated configuration before deploying.
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 update a secret for a Worker
npx wrangler secret put [KEY]pnpm wrangler secret put [KEY]yarn wrangler secret put [KEY]-
[KEY]string requiredThe variable name to be accessible in the Worker
-
--namestringName of the Worker. If this is not specified, it will default to the name specified in your Wrangler config file.
Global flags
-
--vboolean alias: --versionShow version number
-
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
-
--configstring alias: --cPath to Wrangler configuration file
-
--envstring alias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
-
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
-
--experimental-provisionboolean aliases: --x-provision default: trueExperimental: Enable automatic resource provisioning
-
--experimental-auto-createboolean alias: --x-auto-create default: trueAutomatically provision draft bindings with new resources
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 from a Worker
npx wrangler secret delete [KEY]pnpm wrangler secret delete [KEY]yarn wrangler secret delete [KEY]-
[KEY]string requiredThe variable name to be accessible in the Worker
-
--namestringName of the Worker. If this is not specified, it will default to the name specified in your Wrangler config file.
Global flags
-
--vboolean alias: --versionShow version number
-
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
-
--configstring alias: --cPath to Wrangler configuration file
-
--envstring alias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
-
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
-
--experimental-provisionboolean aliases: --x-provision default: trueExperimental: Enable automatic resource provisioning
-
--experimental-auto-createboolean alias: --x-auto-create default: trueAutomatically provision draft bindings with new resources
List all secrets for a Worker
npx wrangler secret listpnpm wrangler secret listyarn wrangler secret list-
--namestringName of the Worker. If this is not specified, it will default to the name specified in your Wrangler config file.
-
--format"json" | "pretty" default: jsonThe format to print the secrets in
Global flags
-
--vboolean alias: --versionShow version number
-
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
-
--configstring alias: --cPath to Wrangler configuration file
-
--envstring alias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
-
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
-
--experimental-provisionboolean aliases: --x-provision default: trueExperimental: Enable automatic resource provisioning
-
--experimental-auto-createboolean alias: --x-auto-create default: trueAutomatically provision draft bindings with new resources
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
npx wrangler secret bulk [FILE]pnpm wrangler secret bulk [FILE]yarn wrangler secret bulk [FILE]-
[FILE]stringThe file of key-value pairs to upload, as JSON in form {"key": value, ...} or .env file in the form KEY=VALUE. If omitted, Wrangler expects to receive input from stdin rather than a file.
-
--namestringName of the Worker. If this is not specified, it will default to the name specified in your Wrangler config file.
Global flags
-
--vboolean alias: --versionShow version number
-
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
-
--configstring alias: --cPath to Wrangler configuration file
-
--envstring alias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
-
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
-
--experimental-provisionboolean aliases: --x-provision default: trueExperimental: Enable automatic resource provisioning
-
--experimental-auto-createboolean alias: --x-auto-create default: trueAutomatically provision draft bindings with new resources
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 upload🦚 Start a log tailing session for a Worker
npx wrangler tail [WORKER]pnpm wrangler tail [WORKER]yarn wrangler tail [WORKER]-
[WORKER]stringName or route of the worker to tail
-
--format"json" | "pretty"The format of log entries
-
--status"ok" | "error" | "canceled"Filter by invocation status
-
--headerstringFilter by HTTP header
-
--methodstringFilter by HTTP method
-
--sampling-ratenumberAdds a percentage of requests to log sampling rate
-
--searchstringFilter by a text match in console.log messages
-
--ipstringFilter by the IP address the request originates from. Use "self" to filter for your own IP
-
--version-idstringFilter by Worker version
Global flags
-
--vboolean alias: --versionShow version number
-
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
-
--configstring alias: --cPath to Wrangler configuration file
-
--envstring alias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
-
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
-
--experimental-provisionboolean aliases: --x-provision default: trueExperimental: Enable automatic resource provisioning
-
--experimental-auto-createboolean alias: --x-auto-create default: trueAutomatically provision draft bindings with new resources
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 ↗.
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.
--scopesstring optional- Allows to choose your set of OAuth scopes. The set of scopes must be entered in a whitespace-separated list,
for example,
npx wrangler login --scopes account:read user:read.
- Allows to choose your set of OAuth scopes. The set of scopes must be entered in a whitespace-separated list,
for example,
--callback-hoststring optional- Defaults to
localhost. Sets the IP or hostname where Wrangler should listen for the OAuth callback.
- Defaults to
--callback-portstring optional- Defaults to
8976. Sets the port where Wrangler should listen for the OAuth callback.
- Defaults to
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
If Wrangler fails to open a browser, you can copy and paste the URL generated by wrangler login in your terminal into a browser and log in.
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>The Cloudflare OAuth provider will always redirect to a callback server at localhost:8976. If you are running Wrangler inside a container, this server might not be accessible from your host machine's browser - even after authorizing the connection, your login command will hang.
You must configure your container to map port 8976 on your host machine to the Wrangler OAuth callback server's port (8976 by default).
For example, if you are running Wrangler in a Docker container:
docker run -p 8976:8976 <your-image>And when you run npx wrangler login inside your container, set the callback host to listen on all network interfaces:
npx wrangler login --callback-host=0.0.0.0Now when the browser redirects to localhost:8976, the request will be forwarded to Wrangler running inside the container on 0.0.0.0:8976.
If you need to use a different port inside the container, use --callback-port as well and adjust your port mapping accordingly, for example:
# When starting your containerdocker run -p 8976:9000 <your-image>
# Inside the containernpx wrangler login --callback-host=0.0.0.0 --callback-port=9000Remove Wrangler's authorization for accessing your account. This command will invalidate your current OAuth token.
wrangler logoutThe following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
If you are using CLOUDFLARE_API_TOKEN instead of OAuth, and you can logout by deleting your API token in the Cloudflare dashboard:
-
In the Cloudflare dashboard, go to the Account API tokens page.
Go to Account API tokens -
Select the three-dot menu on your Wrangler token.
-
Select Delete.
Retrieve your current authentication token or credentials for use with other tools and scripts.
wrangler auth token [OPTIONS]--jsonboolean optional- Return output as JSON with token type information. This also enables retrieving API key/email credentials.
The command returns whichever authentication method is currently configured, in the following order of precedence:
- API token from
CLOUDFLARE_API_TOKENenvironment variable - API key/email from
CLOUDFLARE_API_KEYandCLOUDFLARE_EMAILenvironment variables (requires--jsonflag, since this method uses two values instead of a single token) - OAuth token from
wrangler login(automatically refreshed if expired)
When using --json, the output includes the token type:
// API token{ "type": "api_token", "token": "..." }
// OAuth token{ "type": "oauth", "token": "..." }
// API key/email (only available with --json){ "type": "api_key", "key": "...", "email": "..." }An error is returned if no authentication method is available, or if API key/email is configured without --json.
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
🕵️ Retrieve your user information
npx wrangler whoamipnpm wrangler whoamiyarn wrangler whoami-
--accountstringShow membership information for the given account (id or name).
Global flags
-
--vboolean alias: --versionShow version number
-
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
-
--configstring alias: --cPath to Wrangler configuration file
-
--envstring alias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
-
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
-
--experimental-provisionboolean aliases: --x-provision default: trueExperimental: Enable automatic resource provisioning
-
--experimental-auto-createboolean alias: --x-auto-create default: trueAutomatically provision draft bindings with new resources
Upload a new version of your Worker that is not deployed immediately.
npx wrangler versions upload [SCRIPT]pnpm wrangler versions upload [SCRIPT]yarn wrangler versions upload [SCRIPT]-
[SCRIPT]stringThe path to an entry point for your Worker
-
--namestringName of the Worker
-
--tagstringA tag for this Worker Gradual Rollouts Version
-
--messagestringA descriptive message for this Worker Gradual Rollouts Version
-
--preview-aliasstringName of an alias for this Worker version
-
--no-bundleboolean default: falseSkip internal build steps and directly upload Worker
-
--outdirstringOutput directory for the bundled Worker
-
--outfilestringOutput file for the bundled worker
-
--compatibility-datestringDate to use for compatibility checks
-
--compatibility-flagsstring alias: --compatibility-flagFlags to use for compatibility checks
-
--latestboolean default: falseUse the latest version of the Worker runtime
-
--assetsstringStatic assets to be served. Replaces Workers Sites.
-
--varstringA key-value pair to be injected into the script as a variable
-
--definestringA key-value pair to be substituted in the script
-
--aliasstringA module pair to be substituted in the script
-
--jsx-factorystringThe function that is called for each JSX element
-
--jsx-fragmentstringThe function that is called for each JSX fragment
-
--tsconfigstringPath to a custom tsconfig.json file
-
--minifybooleanMinify the Worker
-
--upload-source-mapsbooleanInclude source maps when uploading this Worker Gradual Rollouts Version.
-
--dry-runbooleanCompile a project without actually uploading the version.
Global flags
-
--vboolean alias: --versionShow version number
-
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
-
--configstring alias: --cPath to Wrangler configuration file
-
--envstring alias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
-
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
-
--experimental-provisionboolean aliases: --x-provision default: trueExperimental: Enable automatic resource provisioning
-
--experimental-auto-createboolean alias: --x-auto-create default: trueAutomatically provision draft bindings with new resources
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.
npx wrangler versions deploy [VERSION-SPECS]pnpm wrangler versions deploy [VERSION-SPECS]yarn wrangler versions deploy [VERSION-SPECS]-
--namestringName of the worker
-
--version-idstringWorker Version ID(s) to deploy
-
--percentagenumberPercentage of traffic to split between Worker Version(s) (0-100)
-
[VERSION-SPECS]stringShorthand notation to deploy Worker Version(s) [<version-id>@<percentage>..]
-
--messagestringDescription of this deployment (optional)
-
--yesboolean alias: --y default: falseAutomatically accept defaults to prompts
-
--dry-runboolean default: falseDon't actually deploy
Global flags
-
--vboolean alias: --versionShow version number
-
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
-
--configstring alias: --cPath to Wrangler configuration file
-
--envstring alias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
-
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
-
--experimental-provisionboolean aliases: --x-provision default: trueExperimental: Enable automatic resource provisioning
-
--experimental-auto-createboolean alias: --x-auto-create default: trueAutomatically provision draft bindings with new resources
Retrieve details for the 10 most recent versions. Details include Version ID, Created on, Author, Source, and optionally, Tag or Message.
npx wrangler versions listpnpm wrangler versions listyarn wrangler versions list-
--namestringName of the Worker
-
--jsonboolean default: falseDisplay output as clean JSON
Global flags
-
--vboolean alias: --versionShow version number
-
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
-
--configstring alias: --cPath to Wrangler configuration file
-
--envstring alias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
-
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
-
--experimental-provisionboolean aliases: --x-provision default: trueExperimental: Enable automatic resource provisioning
-
--experimental-auto-createboolean alias: --x-auto-create default: trueAutomatically provision draft bindings with new resources
View the details of a specific version of your Worker
npx wrangler versions view [VERSION-ID]pnpm wrangler versions view [VERSION-ID]yarn wrangler versions view [VERSION-ID]-
[VERSION-ID]string requiredThe Worker Version ID to view
-
--namestringName of the worker
-
--jsonboolean default: falseDisplay output as clean JSON
Global flags
-
--vboolean alias: --versionShow version number
-
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
-
--configstring alias: --cPath to Wrangler configuration file
-
--envstring alias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
-
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
-
--experimental-provisionboolean aliases: --x-provision default: trueExperimental: Enable automatic resource provisioning
-
--experimental-auto-createboolean alias: --x-auto-create default: trueAutomatically provision draft bindings with new resources
Create or update a secret variable for a Worker
npx wrangler versions secret put [KEY]pnpm wrangler versions secret put [KEY]yarn wrangler versions secret put [KEY]-
[KEY]stringThe variable name to be accessible in the Worker
-
--namestringName of the Worker
-
--messagestringDescription of this deployment
-
--tagstringA tag for this version
Global flags
-
--vboolean alias: --versionShow version number
-
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
-
--configstring alias: --cPath to Wrangler configuration file
-
--envstring alias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
-
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
-
--experimental-provisionboolean aliases: --x-provision default: trueExperimental: Enable automatic resource provisioning
-
--experimental-auto-createboolean alias: --x-auto-create default: trueAutomatically provision draft bindings with new resources
Delete a secret variable from a Worker
npx wrangler versions secret delete [KEY]pnpm wrangler versions secret delete [KEY]yarn wrangler versions secret delete [KEY]-
[KEY]stringThe variable name to be accessible in the Worker
-
--namestringName of the Worker
-
--messagestringDescription of this deployment
-
--tagstringA tag for this version
Global flags
-
--vboolean alias: --versionShow version number
-
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
-
--configstring alias: --cPath to Wrangler configuration file
-
--envstring alias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
-
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
-
--experimental-provisionboolean aliases: --x-provision default: trueExperimental: Enable automatic resource provisioning
-
--experimental-auto-createboolean alias: --x-auto-create default: trueAutomatically provision draft bindings with new resources
Create or update a secret variable for a Worker
npx wrangler versions secret bulk [FILE]pnpm wrangler versions secret bulk [FILE]yarn wrangler versions secret bulk [FILE]-
[FILE]stringThe file of key-value pairs to upload, as JSON in form {"key": value, ...} or .dev.vars file in the form KEY=VALUE
-
--namestringName of the Worker
-
--messagestringDescription of this deployment
-
--tagstringA tag for this version
Global flags
-
--vboolean alias: --versionShow version number
-
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
-
--configstring alias: --cPath to Wrangler configuration file
-
--envstring alias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
-
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
-
--experimental-provisionboolean aliases: --x-provision default: trueExperimental: Enable automatic resource provisioning
-
--experimental-auto-createboolean alias: --x-auto-create default: trueAutomatically provision draft bindings with new resources
Experimental
Apply changes to triggers (Routes or domains and Cron Triggers) when using wrangler versions upload
npx wrangler triggers deploypnpm wrangler triggers deployyarn wrangler triggers deploy-
--namestringName of the worker
-
--triggersstring aliases: --schedule, --schedulescron schedules to attach
-
--routesstring alias: --routeRoutes to upload
-
--dry-runbooleanDon't actually deploy
Global flags
-
--vboolean alias: --versionShow version number
-
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
-
--configstring alias: --cPath to Wrangler configuration file
-
--envstring alias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
-
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
-
--experimental-provisionboolean aliases: --x-provision default: trueExperimental: Enable automatic resource provisioning
-
--experimental-auto-createboolean alias: --x-auto-create default: trueAutomatically provision draft bindings with new resources
Deployments track the version(s) of your Worker that are actively serving traffic.
Displays the 10 most recent deployments of your Worker
npx wrangler deployments listpnpm wrangler deployments listyarn wrangler deployments list-
--namestringName of the Worker
-
--jsonboolean default: falseDisplay output as clean JSON
Global flags
-
--vboolean alias: --versionShow version number
-
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
-
--configstring alias: --cPath to Wrangler configuration file
-
--envstring alias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
-
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
-
--experimental-provisionboolean aliases: --x-provision default: trueExperimental: Enable automatic resource provisioning
-
--experimental-auto-createboolean alias: --x-auto-create default: trueAutomatically provision draft bindings with new resources
View the current state of your production
npx wrangler deployments statuspnpm wrangler deployments statusyarn wrangler deployments status-
--namestringName of the Worker
-
--jsonboolean default: falseDisplay output as clean JSON
Global flags
-
--vboolean alias: --versionShow version number
-
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
-
--configstring alias: --cPath to Wrangler configuration file
-
--envstring alias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
-
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
-
--experimental-provisionboolean aliases: --x-provision default: trueExperimental: Enable automatic resource provisioning
-
--experimental-auto-createboolean alias: --x-auto-create default: trueAutomatically provision draft bindings with new resources
wrangler rollback [<VERSION_ID>] [OPTIONS]VERSION_IDstring optional- The ID of the version you wish to roll back to. If not supplied, the
rollbackcommand defaults to the version uploaded before the latest version.
- The ID of the version you wish to roll back to. If not supplied, the
--namestring optional- Perform on a specific Worker rather than inheriting from the Wrangler configuration file.
--messagestring optional- Add message for rollback. Accepts empty string. When specified, interactive prompts for rollback confirmation and message are skipped.
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
Generate types based on your Worker configuration, including Env types based on your bindings, module rules, and runtime types based on thecompatibility_date and compatibility_flags in your config file.
wrangler types [<PATH>] [OPTIONS]By default, wrangler types generates types for bindings from all environments defined in your configuration file. This ensures your generated Env type includes all bindings that might be used across different deployment environments (such as staging and production), preventing TypeScript errors when accessing environment-specific bindings.
For example, if you have a KV namespace binding only in production and an R2 bucket binding only in staging, both will be included in the generated types as optional properties.
To generate types for only a specific environment, use the --env flag.
PATHstring (default: `./worker-configuration.d.ts`)- The path to where types for your Worker will be written.
- The path must have a
d.tsextension.
--envstring optional- Generate types for bindings in a specific environment only, rather than aggregating bindings from all environments.
--env-interfacestring (default: `Env`)- The name of the interface to generate for the environment object.
- Not valid if the Worker uses the Service Worker syntax.
--include-runtimeboolean (default: true)- Whether to generate runtime types based on the
compatibility_dateandcompatibility_flagsin your config file.
- Whether to generate runtime types based on the
--include-envboolean (default: true)- Whether to generate
Envtypes based on your Worker bindings.
- Whether to generate
--strict-varsboolean optional (default: true)- Control the types that Wrangler generates for
varsbindings. - If
true, (the default) Wrangler generates literal and union types for bindings (e.g.myVar: 'my dev variable' | 'my prod variable'). - If
false, Wrangler generates generic types (e.g.myVar: string). This is useful when variables change frequently, especially when working across multiple environments.
- Control the types that Wrangler generates for
--checkboolean optional- Check if the generated types at the specified path are up-to-date without regenerating them.
- Exits with code 0 if types are up-to-date, or code 1 if types are out-of-date.
- Useful for CI/CD pipelines and pre-commit hooks to ensure types have been regenerated after configuration changes.
--config,-cstring[] optional- Path(s) to Wrangler configuration file. If the Worker you are generating types for has service bindings or bindings to Durable Objects, you can also provide the paths to those configuration files so that the generated
Envtype will include RPC types. For example, given a Worker with a service binding,wrangler types -c wrangler.toml -c ../bound-worker/wrangler.tomlwill generate anEnvtype like this:
TypeScript interface Env {SERVICE_BINDING: Service<import("../bound-worker/src/index").Entrypoint>;}- Path(s) to Wrangler configuration file. If the Worker you are generating types for has service bindings or bindings to Durable Objects, you can also provide the paths to those configuration files so that the generated
Cloudflare collects anonymous usage data to improve Wrangler. You can learn more about this in our data policy ↗.
You can manage sharing of usage data at any time using these commands.
Disable telemetry collection for Wrangler.
wrangler telemetry disableEnable telemetry collection for Wrangler.
wrangler telemetry enableCheck whether telemetry collection is currently enabled. The return result is specific to the directory where you have run the command.
This will resolve the global status set by wrangler telemetry disable / enable, the environment variable WRANGLER_SEND_METRICS, and the send_metrics key in the Wrangler configuration file.
wrangler telemetry statusThe following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
Generate a CPU profile of your Worker's startup phase.
After you run wrangler check startup, you can import the profile into Chrome DevTools or open it directly in VSCode to view a flamegraph of your Worker's startup phase. Additionally, when a Worker deployment fails with a startup time error Wrangler will automatically generate a CPU profile for easy investigation.
wrangler check startup--argsstring optional- To customise the way
wrangler check startupbuilds your Worker for analysis, provide the exact arguments you use when deploying your Worker withwrangler deploy, or your Pages project withwrangler pages functions build. For instance, if you deploy your Worker withwrangler deploy --no-bundle, you should usewrangler check startup --args="--no-bundle"to profile the startup phase.
- To customise the way
--workerstring optional- If you don't use Wrangler to deploy your Worker, you can use this argument to provide a Worker bundle to analyse. This should be a file path to a serialized multipart upload, with the exact same format as the API expects.
--pagesboolean optional- If you don't use a Wrangler config file with your Pages project (i.e. a Wrangler config file containing
pages_build_output_dir), use this flag to forcewrangler check startupto treat your project as a Pages project.
- If you don't use a Wrangler config file with your Pages project (i.e. a Wrangler config file containing
The following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
Generate shell completion scripts for Wrangler commands. Shell completions allow you to autocomplete commands, subcommands, and flags by pressing Tab as you type.
wrangler complete <SHELL>SHELLstring required- The shell to generate completions for. Supported values:
bash,zsh,fish,powershell.
- The shell to generate completions for. Supported values:
Generate and add the completion script to your shell configuration file:
wrangler complete bash >> ~/.bashrcThen restart your terminal or run source ~/.bashrc.
wrangler complete zsh >> ~/.zshrcThen restart your terminal or run source ~/.zshrc.
wrangler complete fish >> ~/.config/fish/config.fishThen restart your terminal or run source ~/.config/fish/config.fish.
wrangler complete powershell >> $PROFILEThen restart PowerShell or run . $PROFILE.
After setup, press Tab to autocomplete commands, subcommands, and flags:
wrangler d<TAB> # completes to 'deploy', 'dev', 'd1', etc.wrangler kv <TAB> # shows subcommands: namespace, key, bulkThe following global flags work on every command:
--helpboolean- Show help.
--configstring (not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.