🤠 wrangler

Banner

crates.io   Build Status

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

Installation

You have many options to install wrangler!

Using npm

npm i @cloudflare/wrangler -g

Using cargo

cargo install wrangler

🎙️ Commands

🔩 Configuration

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

⚓ Installation

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:

    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:

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

    Additional installation methods are available here.

  2. Install wrangler:

    cargo install wrangler

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.

Updating wrangler:

To get the latest version of Wrangler, using Cargo, run:

cargo install wrangler --force

To get the latest version of Wrangler, using NPM, run:

npm install @cloudflare/wrangler

⚡ Quick Start

  1. Generate a new project:

    wrangler generate

  2. Move into the new project directory:

    cd worker

  3. Build your project:

    wrangler build

  4. Preview your project:

    wrangler preview

  5. (optional) Configure with your Cloudflare account:

    wrangler config <email> <api_key>

    Configuring your account is required to use the publish step, which will push your Worker live to the Cloudflare edge. If you don't configure, you can still use wrangler to generate, build, and preview a Worker.

    Optionally, create a workers.dev subdomain:

    wrangler subdomain <name>

  6. Check your configuration:

    wrangler whoami

  7. Publish your project:

    To publish to a workers.dev subdomain: wrangler publish

    To publish to a domain you have registered with Cloudflare, add a route and a zone_id to your wrangler.toml. Then run:

    wrangler publish --release