Commands
Complete list of all commands available for wrangler
↗, the Workers CLI.
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
name
property in the generated Wrangler configuration file.
- The name of the Workers project. This is both the directory name and
-
$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
.
- The type of project; one of
-
--site
optional- When defined, the default
$TEMPLATE
value is changed tocloudflare/workers-sdk/templates/worker-sites
↗. This scaffolds a Workers Site project.
- When defined, the default
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
name
property in the generated Wrangler configuration file.
- The name of the Workers project. This is both the directory name and
-
--type=$TYPE
=webpack optional- The type of project; one of
webpack
,javascript
, orrust
.
- The type of project; one of
-
--site
optional- When defined, the default
$TEMPLATE
value is changed tocloudflare/workers-sdk/templates/worker-sites
↗. This scaffolds a Workers Site project.
- When defined, the default
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]
--env
optional- If defined, Wrangler will load the matching environment's configuration before building. Refer to Environments for more information.
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-list
optional- List all the available OAuth scopes with descriptions.
--scopes $SCOPES
optional- 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
.
- Allows to choose your set of OAuth scopes. The set of scopes must be entered in a whitespace-separated list,
for example,
wrangler login
uses all the available scopes by default if no flags are provided.
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.
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-key
optional- 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.