Get started with Wrangler
Wrangler is a command-line tool for building Cloudflare Workers.
Install
Installing Wrangler, the Workers CLI, allows you to init
, dev
, and publish
your Workers projects.
To install wrangler
, ensure you have npm
and Node.js
installed. Wrangler requires a Node version of 16.13.0
or later.
Then run:
$ npm install -g wrangler
or install with yarn
:
$ yarn global add wrangler
To check your Wrangler version, run:
$ wrangler --version
Authenticate
With installation complete, Wrangler will need access to a Cloudflare OAuth token to manage Workers resources on your behalf.
Run the command wrangler login
, which will automate this process.
Wrangler will attempt to automatically open your web browser to complete the login process to your Cloudflare account. If you have issues completing this step or you do not have access to a browser GUI, you can copy and paste the URL generated by wrangler login
in your terminal into a browser and log in.
$ wrangler login ⛅️ wrangler 2.0.7-----------------------------------------------------Attempting to login via OAuth...Successfully logged in.
If you prefer to use API tokens for authentication, such as in headless or continuous integration environments, refer to Running Wrangler in CI/CD.
Open the browser, log in to your account, and select Allow. This will send an OAuth Token to Wrangler so it can deploy your scripts to Cloudflare.
Update
To update Wrangler, run:
$ npm -g install wrangler@latest
Note that this command will not update Wrangler in projects where it is already installed. If you already have a package.json
in your directory with Wrangler installed, run:
$ npm update wrangler --save
Related resources
With Wrangler successfully installed, refer to Commands and Configuration to continue building with Wrangler.