To publish Cloudflare Workers projects and serve them from our global cloud network, create a Cloudflare account and setup a registered domain or a Workers.dev subdomain on Cloudflare.
Wrangler and other tools use the following credentials to manage uploading and publishing your Worker scripts to your Cloudflare domain:
Workers.dev
subdomain)For domains that you have registered on Cloudflare, you need both IDs:
For workers.dev domains, you will just need the Account ID:
Click Get API Key below the API section to jump to your Profile page. Scroll to API Keys, and click View to copy your Global API Key *.
- IMPORTANT: Treat your Global API Key like a password! It should not be stored in version control or in your code, use environment variables if possible.
Set up your default credentials on your local machine via the config subcommand. You should only need to do this once. Running wrangler config will prompt you interactively for your email and API key:
$ wrangler config
Enter email:
foo@bar.com
Enter api key:
123456abcdef
To configure your project, complete the wrangler.toml file at the root of the generated project. This file contains the information wrangler needs to connect to the Cloudflare Workers API, and publish your code.
The name field in this config file, which will map to your script’s deploy name (e.g. my-worker.mysubdomain.workers.dev
).
Fill in the account_id
field with the value found in your dashboard and type with the type of your project.
# wrangler.toml
# The name of your Workers application
name = "my-worker"
# Your Cloudflare account ID
account_id = "$yourAccountId"
# The kind of application you're deploying to Cloudflare
type = "webpack"
# Publish to workers.dev by default
workers_dev = true