Wrangler v2 no longer uses index.js as default entry point
Wrangler v2 will no longer use index.js in the directory where wrangler dev is called as the entry point to a Worker. Use the main configuration field, or explicitly pass it as a command line argument, for example: wrangler dev index.js.
Wrangler v2 dev and publish commands accept CLI arguments
In Wrangler v2, the dev and publish commands accept CLI arguments.
Wrangler v2 tail command can run on arbitrary Worker names
In Wrangler v2, the tail command can be run on arbitrary Worker names.
Wrangler v2 init creates project boilerplate
In Wrangler v2, the init command creates a project boilerplate.
Wrangler v2 introduces local mode for wrangler dev
Wrangler v2 introduces local mode for wrangler dev.
Wrangler v2 introduces DevTools
Wrangler v2 introduces DevTools.
wrangler route command removed in Wrangler v2
The wrangler route command is removed in Wrangler v2. Routes are defined in the Wrangler configuration file instead.
Wrangler v2 introduces wider platform compatibility
Wrangler v2 introduces wider platform compatibility.
Wrangler v2 introduces developer hotkeys
Wrangler v2 introduces developer hotkeys.
Wrangler is the Cloudflare Developer Platform CLI
Wrangler is the command-line interface (CLI) for the Cloudflare Developer Platform. It allows you to manage Worker projects, including the ability to build, test, and deploy Workers projects.
Update Wrangler command
To update Wrangler to the latest version in your project, run: npm install --save-dev wrangler@latest (or equivalent for other package managers).
npx wrangler uses latest version if Wrangler not installed
If Wrangler is not installed locally in your project, running npx wrangler will use the latest version of Wrangler from npm.
Wrangler is a command-line tool for Cloudflare developer products
Wrangler is a command-line tool for building with Cloudflare developer products.
Wrangler requires Node.js and npm
To install Wrangler, Node.js and npm must be installed. A Node version manager like mise or nvm is recommended to avoid permission issues and allow changing Node.js versions.
Supported Node.js versions for Wrangler
Wrangler is supported on the Current, Active, and Maintenance versions of Node.js as defined by the Node.js release schedule.
Supported operating systems for Wrangler
Wrangler is supported on macOS 13.5 or later, Windows 11, and Linux distributions that support glib 2.35. This follows workerd's OS support policy.
Workers execute in workerd runtime
Worker code is always executed in workerd, which is the open source Cloudflare Workers runtime.
Install Wrangler locally in each project
Wrangler is installed locally into each project rather than globally. This allows teams to use the same Wrangler version, control versions for each project, and roll back to an earlier version if needed.
How to install Wrangler
To install Wrangler as a dev dependency in your project, run: npm install --save-dev wrangler@latest (or equivalent for other package managers like yarn add --dev wrangler@latest or pnpm add -D wrangler@latest).
Check Wrangler version command
To check the installed Wrangler version, run npx wrangler --version or npx wrangler -v.
CLOUDFLARE_ENV environment variable for selecting active environment
The CLOUDFLARE_ENV environment variable can be used to select the active environment. For example, 'CLOUDFLARE_ENV=dev npx wrangler deploy' deploys to the dev environment. The --env command line argument takes precedence over the CLOUDFLARE_ENV environment variable.
Deploy to specific environment with --env flag
Environments are used with the --env or -e flag on Wrangler commands. For example, 'npx wrangler dev -e=dev' develops in the dev environment, and 'npx wrangler deploy -e=dev' deploys to the dev environment.
Wrangler v2 to v3 migration
There are no special instructions required for migrating from Wrangler v2 to v3. You should be able to update Wrangler by following the standard install/update instructions with no disruption to your workflow.
Wrangler v3 compatibility with older operating systems
If you attempted to update to Wrangler v3 prior to version v3.3, you may have experienced compatibility issues with older operating systems. These issues have been resolved in the latest v3 version.
Wrangler v3 deprecations reference
Wrangler v3 has deprecated features and functionality that were supported in v2. Details on what is no longer supported in v3 can be found in the Deprecations documentation.
wrangler generate command removed in Wrangler v4
The `wrangler generate` command is removed in Wrangler v4. Use `npm create cloudflare@latest` instead.
Wrangler v4 Node.js support policy
Wrangler v4 supports only Node.js versions that align with Node.js's official lifecycle: Current, Active LTS, and Maintenance LTS versions. Node.js v16 (EOL in 2022) is no longer supported. Users on Node.js v16 or v18 must upgrade to a supported version.
Wrangler v4 commands default to local mode
All commands that can run in either local or remote mode now default to local mode by default in Wrangler v4. To query via the API and interact with remote/production data, an explicit `--remote` flag is required. For example, `wrangler kv key get` now queries locally unless `--remote` is specified.
KV commands affected by local mode default
The following KV commands are affected by the Wrangler v4 default to local mode and require the `--remote` flag to interact with remote data: `wrangler kv key get`, `wrangler kv key put`, `wrangler kv key delete`, `wrangler kv key list`, `wrangler kv bulk put`, `wrangler kv bulk delete`.
R2 commands affected by local mode default
The following R2 commands are affected by the Wrangler v4 default to local mode and require the `--remote` flag to interact with remote data: `wrangler r2 object get`, `wrangler r2 object put`, `wrangler r2 object delete`.
wrangler version command removed in Wrangler v4
The `wrangler version` command is removed in Wrangler v4. Use `wrangler --version` instead to check the current version of Wrangler.
getBindingsProxy API removed in Wrangler v4
The `getBindingsProxy()` API (via `import { getBindingsProxy } from "wrangler"`) is removed in Wrangler v4. Use the `getPlatformProxy()` API instead, which takes exactly the same arguments.
wrangler pages publish command removed in Wrangler v4
The `wrangler pages publish` command is removed in Wrangler v4. Use `wrangler pages deploy` instead.
Wrangler v1 to v2 migration guide exists
There is a step-by-step guide available for migrating Cloudflare Workers projects from Wrangler v1 to v2, including information about webpack changes during the migration process.
Wrangler v2 migration overview
Wrangler v2 ships with new features and improvements that may require configuration changes. Before updating, review the Migrate webpack projects from Wrangler version 1 guide if webpack applies to your project. The CLI will guide you through the upgrade process.
Uninstall Wrangler v1 globally via npm
To uninstall Wrangler v1 that was previously installed globally using npm, run: npm uninstall -g @cloudflare/wrangler
Uninstall Wrangler v1 via Cargo
To uninstall Wrangler v1 that was previously installed via Cargo, run: cargo uninstall wrangler
Install latest Wrangler version
To install the latest version of Wrangler, run: npm install -g wrangler
Verify Wrangler version after installation
To check that you have installed the correct Wrangler version, run: npx wrangler --version
Test Wrangler v2 on previous projects
To test that Wrangler v2 can build your Wrangler v1 project, run: npx wrangler dev. In most cases it will build just fine. If there are errors, the command line will instruct with exactly what to change. Errors must be fixed before Wrangler can build your Worker. Warnings do not stop Wrangler from building but should be considered for updating the configuration.
Wrangler v1 config with API token
Running wrangler config without flags configures Wrangler with an API token and stores default credentials on your local machine.
Wrangler v1 whoami command
The whoami command confirms that your configuration is appropriately set up. When successful, it prints out your account email and your account_id needed for your project's Wrangler file.
Wrangler v1 config --api-key flag
The --api-key flag is used with the wrangler config command to configure Wrangler with email and global API key instead of an API token.
Wrangler v1 login command
The login command opens a Cloudflare account login page to authorize Wrangler.
Wrangler v1 config command
The config command is an alternative to login that prompts you to enter your email and API key.
Deploying to environment in Wrangler v1
To deploy a Worker to a specific environment in Wrangler v1, use the --env flag with the environment name. For example: wrangler deploy --env helloworld deploys to the helloworld environment.
Wrangler v1 is deprecated and legacy
Wrangler v1 is deprecated and legacy documentation. Users should migrate to the latest version of Wrangler for current CLI functionality and features.
wrangler tail command
The `wrangler tail` command starts a session to livestream logs from a deployed Worker. Syntax: `wrangler tail [--format $FORMAT] [--status $STATUS] [OPTIONS]`. Flags: `--format $FORMAT` (values: json, pretty) sets log entry format; `--status $STATUS` filters by invocation status (ok, error, canceled); `--header $HEADER` filters by HTTP header; `--method $METHOD` filters by HTTP method; `--sampling-rate $RATE` sets request logging percentage; `--search $SEARCH` filters by text match in console.log messages. Run from the Worker's root directory. Wrangler versions older than 1.19.0 that use cloudflared should be updated to avoid issues.
wrangler kv:key delete command
The `wrangler kv:key delete` command removes a key-value pair from a namespace. Syntax: `wrangler kv:key delete --binding= [--env=] [--preview] [--namespace-id=] "$KEY"`. Required parameter: `$KEY`. Either `--binding` or `--namespace-id` is required. Optional flags: `--env` applies to specified environment; `--preview` deletes from preview namespace.
wrangler generate command
The `wrangler generate` command scaffolds a Cloudflare Workers project from a public GitHub repository. Syntax: `wrangler generate [$NAME] [$TEMPLATE] [--type=$TYPE] [--site]`. Parameters: `$NAME` (default: worker) is the project name and directory name; `$TEMPLATE` (default: https://github.com/cloudflare/worker-template) is the GitHub URL of the template repository; `--type=$TYPE` (default: webpack, options: webpack, javascript, rust) specifies project type; `--site` changes the default template to cloudflare/workers-sdk/templates/worker-sites for Workers Site projects.
wrangler init command
The `wrangler init` command creates a skeleton Wrangler configuration file in an existing directory. Syntax: `wrangler init [$NAME] [--type=$TYPE] [--site]`. Parameters: `$NAME` (default: name of working directory) is the project name; `--type=$TYPE` (default: webpack, options: webpack, javascript, rust) specifies project type; `--site` scaffolds a Workers Site project.
wrangler build command
The `wrangler build` command builds a project based on the `type` value in the Wrangler file. For `type = "webpack"`, Wrangler uses its internal webpack installation. For `type = "javascript"`, the `build.command` in configuration is run if defined. Syntax: `wrangler build [--env $ENVIRONMENT_NAME]`. Flag `--env` loads the matching environment's configuration before building.
wrangler login command
The `wrangler login` command authorizes Wrangler with a Cloudflare account using OAuth tokens. It opens a login page in the browser. Syntax: `wrangler login [--scopes-list] [--scopes $SCOPES]`. Flag `--scopes-list` lists all available OAuth scopes. Flag `--scopes $SCOPES` allows choosing a whitespace-separated set of scopes (e.g., `wrangler login --scopes account:read user:read`). All available scopes are used by default if no flags are provided.
wrangler logout command
The `wrangler logout` command removes Wrangler's authorization for accessing the account. It invalidates the current OAuth token and deletes the configuration file if present. This only affects OAuth tokens acquired through `wrangler login`, but attempts to delete the configuration file regardless of authorization method. API tokens must be deleted manually in the Cloudflare dashboard.
wrangler config command
The `wrangler config` command configures Wrangler with a Cloudflare API Token or Global API key for accessing account resources. Syntax: `wrangler config [--api-key]`. Flag `--api-key` prompts for email and global API key instead of a token (not recommended for security reasons). Environment variables or `wrangler login` can also be used for authentication.
wrangler publish command
The `wrangler publish` command publishes a Worker to Cloudflare. Syntax: `wrangler publish [--env $ENVIRONMENT_NAME]`. Flag `--env` loads the matching environment's configuration before building and deploying. Required fields in Wrangler file: `name` (string, the project name), `type` (string, one of webpack/javascript/rust), `account_id` (string, the Cloudflare account ID). When publishing changes to an existing Worker, all new requests route to the updated version without downtime; inflight requests continue on the previous version until completion, then the previous version is purged.
wrangler publish to workers.dev
To publish a Worker to a `*.workers.dev` subdomain, first register a subdomain using `wrangler subdomain` command, then add `workers_dev = true` to the Wrangler file.
wrangler publish to custom domain
To publish a Worker to a custom domain, specify these three fields in the Wrangler file: `zone_id` (string, the Cloudflare zone ID, e.g., `zone_id = "b6558acaf2b4cad1f2b51c5236a6b972"`), `route` (string, the route pattern, e.g., `route = "example.com/my-worker/*"`), or `routes` (array, multiple route patterns, e.g., `routes = ["example.com/foo/*", "example.com/bar/*"]`). Use only `route` or `routes`, not both.
wrangler dev command
The `wrangler dev` command establishes a connection between localhost and a global network server that operates the Worker in development. A cloudflared tunnel forwards requests to the global network server, which continuously updates as Worker code changes. This allows full access to Workers KV, Durable Objects, and other Cloudflare developer platform products. Syntax: `wrangler dev [--env $ENVIRONMENT_NAME] [--ip <ip>] [--port <port>] [--host <host>] [--local-protocol <http|https>] [--upstream-protocol <http|https>]`. Flags: `--env` loads matching environment configuration; `--ip` (default: 127.0.0.1) sets the listening IP; `--port` (default: 8787) sets the listening port; `--host` (default: zone or tutorial.cloudflareworkers.com if unauthenticated) sets the forwarding host; `--local-protocol` (default: http) sets the listening protocol; `--upstream-protocol` (default: https) sets the forwarding protocol.
wrangler preview command
The `wrangler preview` command previews a project using the Cloudflare Workers preview service. Syntax: `wrangler preview [--watch] [--env $ENVIRONMENT_NAME] [--url $URL] [$METHOD] [$BODY]`. Flags: `--env $ENVIRONMENT_NAME` loads matching environment configuration; `--watch` (recommended) continually updates preview with newest version; `$METHOD` (default: GET) specifies request type (GET, POST); `$BODY` (default: Null) specifies request body string (e.g., `wrangler preview post hello=hello`). For KV namespaces, specify `preview_id` in Wrangler file to avoid accidentally modifying production data.