shiichan

Switch Cloudflare accounts without logging in again: Wrangler auth profiles!

Hey there, it's Shiichan! Today I've got a small but genuinely handy update for everyone using Wrangler. If you juggle multiple Cloudflare accounts, this one's for you!

Cloudflare Changelog developers.cloudflare.com

What was announced?

Over on Cloudflare's Changelog, Wrangler CLI added "auth profiles": named logins that you scope to specific Cloudflare accounts and switch between automatically, based on the directory you're working in.

A profile is a named OAuth login bound to a directory. Commands run in that directory, and its subdirectories, use the matching account.

The story so far

Until now, every time you wanted to work under a different account, you had to re-run wrangler login. If you were juggling several clients at an agency, or keeping staging and production in separate accounts, that meant logging in again on every switch — a bit of a hassle.

What changes

With auth profiles, you can move between accounts without re-running wrangler login.

  • At an agency, keep a separate login for each client
  • Split staging and production into different accounts

Profiles also act as a guard so a command cannot reach the wrong account.

Dive Deep

Here's how it works. First create a profile per account and assign it to a directory.

# Create a profile for each account
wrangler auth create client-a
wrangler auth activate client-a ~/clients/client-a

wrangler auth create client-b
wrangler auth activate client-b ~/clients/client-b

To run a single command with a specific profile, use the --profile flag.

wrangler deploy --profile personal

For extra safety, pair a profile with the account_id in your Wrangler configuration file so a command cannot reach the wrong account.

One thing to note: in CI and other automated environments, the CLOUDFLARE_API_TOKEN environment variable still takes precedence over all profiles. So your CI keeps working the same way.

For setup, the resolution order, and the full command reference, check the Authentication profiles docs.

Wrap-up

  • Wrangler CLI adds auth profiles: named logins bound to specific accounts
  • Accounts switch automatically by directory, so no more re-running wrangler login
  • Use the --profile flag to target a single command
  • Pair with account_id to prevent reaching the wrong account
  • In CI, CLOUDFLARE_API_TOKEN takes precedence

This is a perfect fit for Workers developers juggling multiple Cloudflare accounts and for agencies doing client work!