🤠 wrangler

Banner

crates.io Build Status

Get started with Cloudflare Workers and Wrangler by reading the documentation.

Installation

You have many options to install wrangler!

Using npm

npm i @cloudflare/wrangler -g

Using cargo

cargo install wrangler

🎙️ Commands

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

🔩 Configuration

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

⚓ Installation

  1. Install cargo:

    Wrangler is installed through Cargo, a Rust package manager. 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

  3. Troubleshooting OpenSSL errors

    If you are on a Mac, you might encounter an OpenSSL error when attempting to generate a project. You can resolve that issue by installing OpenSSL v1.1 through Homebrew (need to install Homebrew? Instructions available here).

    $ brew install openssl@1.1

⚡ 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