🤠 wrangler

Banner

crates.io   Build Status

wrangler is a CLI tool designed for folks who are interested in using Cloudflare Workers.

Wrangler Demo

Installation

You have many options to install wrangler!

Install with npm

bash npm i @cloudflare/wrangler -g

Install with cargo

bash cargo install wrangler

If you don't have cargo or npm installed, you will need to follow these additional instructions.

Updating

For information regarding updating Wrangler, click here.

Additional Documentation

General documentation surrounding workers development and using wrangler can be found here. This documentation will be highly valuable to you when developing with wrangler.

🎙️ Commands

Publishing to workers.dev

If you want to publish to workers.dev, you will first need to have a workers.dev subdomain registered. You can register a subdomain by executing:

bash wrangler subdomain <name>

After you have registered a subdomain, add workers_dev to your wrangler.toml.

| Key | Value | Example | | --------------- | ----- | ------------------------ | | workers_dev | true | workers_dev = true |

Publishing to your own domain

If you would like to publish to your own domain, you will need to specify these three fields in your wrangler.toml.

| Key | Value | Example | | --------------- | ---------------------------------------------------------------------- | ---------------------------------------------- | | workersdev | false | workers_dev = false | | route | The route you would like to publish to | route = "example.com/my-worker/*" | | zoneid | Your Cloudflare zone ID, this can be found in the Cloudflare dashboard | zone_id = "b6558acaf2b4cad1f2b51c5236a6b972" |

Publishing the same code to multiple places

If you would like to be able to publish your code to multiple places, please see the documentation for environments.

🔩 Configuration

There are two types of configuration that wrangler uses: global user and per project.

Additional Installation Instructions

Wrangler can be installed both through npm and through Rust's package manager, Cargo.

Using npm

  1. If you don't already have npm on your machine, install it using npm's recommended method, a node.js version manager.

    If you have already installed npm with a package manager, it is possible you will run into an EACCES error while installing wrangler. This is related to how many system packagers install npm. You can either uninstall npm and reinstall using the npm recommended install method (a version manager), or use one of our other install methods.

  2. Install Wrangler by running:

    bash npm i @cloudflare/wrangler -g

Using cargo

  1. Install cargo:

    Rustup, a tool for installing Rust, will also install Cargo. On Linux and macOS systems, rustup can be installed as follows:

    bash curl https://sh.rustup.rs -sSf | sh

    Additional installation methods are available here.

  2. Install wrangler:

    bash cargo install wrangler

    Installing wrangler on linux requires some OpenSSL-related packages to be installed. If you don't want to deal with this, you can use vendored OpenSSL.

    bash cargo install wrangler --features vendored-openssl

Manual Install

  1. Download the binary tarball for your platform from our releases page. You don't need to download wranglerjs, wrangler will install that for you.

  2. Unpack the tarball and place the binary wrangler somewhere on your PATH, preferably /usr/local/bin for linux/macOS or Program Files for windows.