Commands (3)
Last updated Apr 23, 2026 Caution
This page is for Wrangler v1, which has been deprecated. Learn how to update to the latest version of Wrangler.
Complete list of all commands available for wrangler ↗︎, the Workers CLI.
generate
Scaffold a Cloudflare Workers project from a public GitHub repository.
wrangler generate [$NAME] [$TEMPLATE] [--type=$TYPE] [--site]
Default values indicated by =value.
$NAME=worker optional- The name of the Workers project. This is both the directory name and
nameproperty in the generated Wrangler configuration file. $TEMPLATE= https://github.com/cloudflare/worker-template ↗︎ optional- The GitHub URL of the repository to use as the template ↗︎ for generating the project.
--type=$TYPE=webpack optional- The type of project; one of
webpack,javascript, orrust. --siteoptional- When defined, the default
$TEMPLATEvalue is changed tocloudflare/workers-sdk/templates/worker-sites↗︎. This scaffolds a Workers Site project.
init
Create a skeleton Wrangler configuration file in an existing directory. This command can be used as an alternative to generate if you prefer to clone a template repository yourself or you already have a JavaScript project and would like to use Wrangler.
wrangler init [$NAME] [--type=$TYPE] [--site]
Default values indicated by =value.
$NAME=(Name of working directory) optional- The name of the Workers project. This is both the directory name and
nameproperty in the generated Wrangler configuration file. --type=$TYPE=webpack optional- The type of project; one of
webpack,javascript, orrust. --siteoptional- When defined, the default
$TEMPLATEvalue is changed tocloudflare/workers-sdk/templates/worker-sites↗︎. This scaffolds a Workers Site project.
build
Build your project (if applicable). This command looks at your Wrangler file and reacts to the "type" value specified.
When using type = "webpack", Wrangler will build the Worker using its internal webpack installation. When using type = "javascript" , the build.command, if defined, will run.
wrangler build [--env $ENVIRONMENT_NAME]
--envoptional- If defined, Wrangler will load the matching environment's configuration before building. Refer to Environments for more information.
login
Authorize Wrangler with your Cloudflare account. This will open a login page in your browser and request your account access permissions. This command is the alternative to wrangler config and it uses OAuth tokens.
wrangler login [--scopes-list] [--scopes $SCOPES]
All of the arguments and flags to this command are optional:
--scopes-listoptional- List all the available OAuth scopes with descriptions.
--scopes $SCOPESoptional- Allows to choose your set of OAuth scopes. The set of scopes must be entered in a whitespace-separated list, for example,
wrangler login --scopes account:read user:read.
wrangler login uses all the available scopes by default if no flags are provided.
logout
Remove Wrangler's authorization for accessing your account. This command will invalidate your current OAuth token and delete the configuration file, if present.
wrangler logout
This command only invalidates OAuth tokens acquired through the wrangler login command. However, it will try to delete the configuration file regardless of your authorization method.
To delete your API token:
- In the Cloudflare dashboard, go to the Workers & Pages page. Go to Workers & Pages ↗
- In the Overview > Get your API token in the right side menu.
- Select the three-dot menu on your Wrangler token and select Delete.
config
Configure Wrangler so that it may acquire a Cloudflare API Token or Global API key, instead of OAuth tokens, in order to access and manage account resources.
wrangler config [--api-key]
--api-keyoptional- To provide your email and global API key instead of a token. (This is not recommended for security reasons.)
You can also use environment variables to authenticate, or wrangler login to authorize with OAuth tokens.
publish
Publish your Worker to Cloudflare. Several keys in your Wrangler file determine whether you are publishing to a *.workers.dev subdomain or a custom domain. However, custom domains must be proxied (orange-clouded) through Cloudflare. Refer to the Get started guide for more information.
wrangler publish [--env $ENVIRONMENT_NAME]
--envoptional- If defined, Wrangler will load the matching environment's configuration before building and deploying. Refer to Environments for more information.
To use this command, the following fields are required in your Wrangler file:
namestring- The name of the Workers project. This is both the directory name and
nameproperty in the generated Wrangler configuration file. typestring- The type of project; one of
webpack,javascript, orrust. account_idstring- The Cloudflare account ID. This can be found in the Cloudflare dashboard, for example,
account_id = "a655bacaf2b4cad0e2b51c5236a6b974".
You can publish to \<your-worker>.\<your-subdomain>.workers.dev ↗︎ or to a custom domain.
When you publish changes to an existing Worker script, all new requests will automatically route to the updated version of the Worker without downtime. Any inflight requests will continue running on the previous version until completion. Once all inflight requests have finished complete, the previous Worker version will be purged and will no longer handle requests.
Publishing to workers.dev
To publish to *.workers.dev ↗︎, you will first need to have a subdomain registered. You can register a subdomain by executing the wrangler subdomain command.
After you have registered a subdomain, add workers_dev to your Wrangler file.
workers_devbool- When
true, indicates that the Worker should be deployed to a*.workers.devdomain.
Publishing to your own domain
To publish to your own domain, specify these three fields in your Wrangler file.
zone_idstring- The Cloudflare zone ID, for example,
zone_id = "b6558acaf2b4cad1f2b51c5236a6b972", which can be found in the Cloudflare dashboard. routestring- The route you would like to publish to, for example,
route = "example.com/my-worker/*". routesArray- The routes you would like to publish to, for example,
routes = ["example.com/foo/*", example.com/bar/*].
Note
Make sure to use only route or routes, not both.
Publishing the same code to multiple domains
To publish your code to multiple domains, refer to the documentation for environments.
dev
wrangler dev is a command that establishes a connection between localhost and a global network server that operates your Worker in development. A cloudflared tunnel forwards all requests to the global network server, which continuously updates as your Worker code changes. This allows full access to Workers KV, Durable Objects and other Cloudflare developer platform products. The dev command is a way to test your Worker while developing.
wrangler dev [--env $ENVIRONMENT_NAME] [--ip <ip>] [--port <port>] [--host <host>] [--local-protocol <http|https>] [--upstream-protocol <http|https>]
--envoptional- If defined, Wrangler will load the matching environment's configuration. Refer to Environments for more information.
--ipoptional- The IP to listen on, defaults to
127.0.0.1. --portoptional- The port to listen on, defaults to
8787. --hostoptional- The host to forward requests to, defaults to the zone of the project or to
tutorial.cloudflareworkers.comif unauthenticated. --local-protocoloptional- The protocol to listen to requests on, defaults to
http. --upstream-protocoloptional- The protocol to forward requests to host on, defaults to
https.
These arguments can also be set in your Wrangler file. Refer to the wrangler dev configuration documentation for more information.
Usage
You should run wrangler dev from your Worker directory. Wrangler will run a local server accepting requests, executing your Worker, and forwarding them to a host. If you want to use another host other than your zone or tutorials.cloudflare.com, you can specify with --host example.com.
wrangler dev
💁 JavaScript project found. Skipping unnecessary build!
💁 watching "./"
👂 Listening on http://127.0.0.1:8787
With wrangler dev running, you can 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. If either of these things do not happen, or you think the output is incorrect, file an issue ↗︎.
tail
Start a session to livestream logs from a deployed Worker.
wrangler tail [--format $FORMAT] [--status $STATUS] [OPTIONS]
--format $FORMATjson|pretty- The format of the log entries.
--status $STATUS- Filter by invocation status [possible values:
ok,error,canceled]. --header $HEADER- Filter by HTTP header.
--method $METHOD- Filter by HTTP method.
--sampling-rate $RATE- Add a percentage of requests to log sampling rate.
--search $SEARCH- Filter by a text match in
console.logmessages.
After starting wrangler tail in a directory with a project, you will receive a live feed of console and exception logs for each request your Worker receives.
Like all Wrangler commands, run wrangler tail from your Worker’s root directory (the directory with your Wrangler file).
Legacy issues with existing cloudflared configuration
wrangler tail versions older than version 1.19.0 use cloudflared to run. Update to the latest Wrangler version to avoid any issues.
preview
Preview your project using the Cloudflare Workers preview service ↗︎.
wrangler preview [--watch] [--env $ENVIRONMENT_NAME] [ --url $URL] [$METHOD] [$BODY]
Default values indicated by =value.
--env $ENVIRONMENT_NAMEoptional- If defined, Wrangler will load the matching environment's configuration. Refer to Environments for more information.
--watchrecommended- When enabled, any changes to the Worker project will continually update the preview service with the newest version of your project. By default,
wrangler previewwill only bundle your project a single time. $METHOD="GET" optional- The type of request to preview your Worker with (
GET,POST). $BODY="Null" optional- The body string to post to your preview Worker request. For example,
wrangler preview post hello=hello.
