- Notifications
You must be signed in to change notification settings - Fork335
🤠 Home to Wrangler v1 (deprecated)
License
Apache-2.0, MIT licenses found
Licenses found
cloudflare/wrangler-legacy
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
🛑 This repository is for Wrangler version 1, which is deprecated and no longer updated. This repository is now archived.
New versions of Wrangler are maintained in theWorkers SDK repository.
Legacy Documentation
wrangler
is a CLI tool designed for folks who are interested in usingCloudflare Workers.
You have many options to install wrangler!
For the latest version, seehttps://github.com/cloudflare/workers-sdk
We strongly recommend you installnpm
with a Node version manager likenvm
, which puts the globalnode_modules
in your home directory to eliminate permissions issues withnpm install -g
. Distribution-packagednpm
installs often use/usr/lib/node_modules
(which is root) for globally installednpm
packages, and runningnpm install -g
asroot
preventswrangler
from installing properly.
Once you've installednvm
and configured your system to use thenvm
managed node install, run:
npm i @cloudflare/wrangler -g
If you are running an ARM based system (eg Raspberry Pi, Pinebook) you'll need to use thecargo
installation method listed below to build wrangler from source.
In case you needwrangler
's npm installer to place the binary in a non-default location (such as when usingwrangler
in CI), you can use the following configuration options to specify an install location:
- Environment variable:
WRANGLER_INSTALL_PATH
- NPM configuration:
wrangler_install_path
In case you need to store/mirror binaries on premise you will need to specify where wrangler should search for them by providing any of the following:
- Environment variable:
WRANGLER_BINARY_HOST
- NPM configuration:
wrangler_binary_host
cargo install wrangler
If you don't havecargo
ornpm
installed, you will need to follow theseadditional instructions.
perl is an external dependency of crate openssl-sys. If installing wrangler with cargo, you will need to have perl installed. We've tested withStrawberry Perl. If you instead install perl via scoop, you may need to also runscoop install openssl
in order to get the necessary openssl dlls. Installing wrangler withnpm
instead of cargo is another option if you don't want to install perl.
For information regarding updating Wrangler, clickhere.
Once you have installed Wrangler, spinning up and deploying your first Worker is easy!
$wrangler generate my-worker$cd my-worker#update your wrangler.toml with your Cloudflare Account ID$wrangler config$wrangler publish
Scaffold a project, including boilerplate code for a Rust library and a Cloudflare Worker.
wrangler generate<name><template> --type=["webpack","javascript","rust"]
All of the arguments and flags to this command are optional:
name
: defaults toworker
template
: defaults to thehttps://github.com/cloudflare/worker-template
type
: defaults tojavascript
based on the"worker-template"
Creates a skeletonwrangler.toml
in an existing directory. This can be used as an alternative togenerate
if you prefer to clone a repository yourself.
wrangler init<name> --type=["webpack","javascript","rust"]
All of the arguments and flags to this command are optional:
name
: defaults to the name of your working directorytype
: defaults to"webpack".
Build your project. This command looks at yourwrangler.toml
file and runs the build steps associatedwith the"type"
declared there.
Additionally, you can configure differentenvironments.
Authorize Wrangler with your Cloudflare login. This will prompt you with a Cloudflare account login page and a permissions consent page.This command is the alternative towrangler config
and it uses OAuth tokens.
wrangler login --scopes-list --scopes<scopes>
All of the arguments and flags to this command are optional:
scopes-list
: list all the available OAuth scopes with descriptions.scopes
: allows to choose your set of OAuth scopes.
Read more about this command inWrangler Login Documentation.
Authenticate Wrangler with a Cloudflare API Token. This is an interactive command that will prompt you for your API token:
wrangler configEnter API token:superlongapitoken
You can also provide your email and global API key (this is not recommended for security reasons):
wrangler config --api-keyEnter email:testuser@example.comEnter global API key:superlongapikey
You can alsouse environment variables to configure these values.
Publish your Worker to Cloudflare. Several keys in yourwrangler.toml
determine whether you are publishing to a workers.dev subdomain or your own registered domain, proxied through Cloudflare.
Additionally, you can configure differentenvironments.
You can also use environment variables to handle authentication when you publish a Worker.
# e.g.CF_API_TOKEN=superlongtoken wrangler publish# where# $CF_API_TOKEN -> your Cloudflare API tokenCF_API_KEY=superlongapikey CF_EMAIL=testuser@example.com wrangler publish# where# $CF_API_KEY -> your Cloudflare API key# $CF_EMAIL -> your Cloudflare account email
Interact with your Workers KV store. This is actually a whole suite of subcommands. Read more about inWrangler KV Documentation.
wrangler dev
works very similarly towrangler preview
except that instead of opening your browser to preview your worker, it will start a server on localhost that will execute your worker on incoming HTTP requests. From there you can use cURL, Postman, your browser, or any other HTTP client to test the behavior of your worker before publishing it.
You should run wrangler dev from your worker directory, and if your worker makes any requests to a backend, you should specify the host with--host example.com
.
From here you should be able to send HTTP requests tolocalhost:8787
along with any headers and paths, and your worker should execute as expected. Additionally, you should see console.log messages and exceptions appearing in your terminal.
👂 Listening on http://localhost:8787[2020-02-18 19:37:08] GET example.com/ HTTP/1.1 200 OK
All of the arguments and flags to this command are optional:
env
: environment to buildhost
: domain to test behind your worker. defaults to example.comip
: ip to listen on. defaults to localhostport
: port to listen on. defaults to 8787
All information regarding wrangler or Cloudflare Workers is located in theCloudflare Workers Developer Docs. This includes:
- Using wranglercommands
- Wranglerconfiguration
- General documentation surrounding Workers development
- All wrangler features such as Workers Sites and KV
To learn about deploying static assets usingwrangler
, see theWorkers Sites Quickstart.
About
🤠 Home to Wrangler v1 (deprecated)