Skip to content
Cloudflare Docs

Commands

Complete list of all commands available for wrangler, the Workers CLI.


generate

Scaffold a Cloudflare Workers project from a public GitHub repository.

Terminal window
wrangler generate [$NAME] [$TEMPLATE] [--type=$TYPE] [--site]

Default values indicated by =value.


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.

Terminal window
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.
  • --type=$TYPE =webpack optional

    • The type of project; one of webpack, javascript, or rust.
  • --site optional


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.

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

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.

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

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.

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

  1. In the Cloudflare dashboard, go to the Workers & Pages page.

    Go to Workers & Pages
  2. In the Overview > Get your API token in the right side menu.

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

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


publish