Skip to content

Conversation

@LukasMurdock
Copy link

@LukasMurdock LukasMurdock commented Dec 31, 2025

Adds multi-account profile support to Wrangler, inspired by AWS CLI's profile system.

Summary

This PR introduces a profile system that allows users to store and switch between multiple Cloudflare user identities (OAuth tokens or API tokens) without re-authenticating.

Why

The Problem: Wrangler currently supports only a single authenticated user at a time. Developers who work across multiple Cloudflare accounts (personal projects, work, client accounts, staging vs production) must repeatedly run wrangler login to switch between them, losing their previous session each time.

Use Cases:

  • Agency/Consulting work: Developers managing Workers for multiple clients need to deploy to different accounts throughout the day
  • Work + Personal: Separating personal side projects from employer's Cloudflare account
  • Staging + Production: Teams using separate Cloudflare accounts for staging and production environments
  • Open source maintainers: Contributing to projects across different organizations

Pain Points Addressed:

  • No more re-authenticating every time you switch contexts
  • No more juggling environment variables or manually swapping config files
  • Clear visibility into which identity you're authenticated as

Workflow Unlocks:

  • Set a project-level profile once (.wrangler/profile) and forget about it
  • Quickly check which profile is active before running commands
  • Script deployments to multiple accounts using --profile or WRANGLER_PROFILE
  • Onboard to a new client/project without disrupting existing work

New Commands

  • wrangler profile list - List all configured profiles with status
  • wrangler profile current - Show the currently active profile and how it was resolved
  • wrangler profile use <name> - Set the active profile (project-level by default, --global for global)
  • wrangler profile delete <name> - Delete a profile

New Flags

  • wrangler login --profile <name> - Save credentials to a specific profile
  • wrangler auth token --profile <name> - Get token from a specific profile

Profile Resolution Precedence

  1. --profile CLI flag (highest)
  2. WRANGLER_PROFILE environment variable
  3. .wrangler/profile (project-level)
  4. ~/.wrangler/current-profile (global)
  5. default profile (lowest)

File Locations

  • ~/.wrangler/credentials - All profiles (TOML format, 600 permissions)
  • ~/.wrangler/current-profile - Global active profile
  • .wrangler/profile - Project-level active profile

Migration

Existing OAuth tokens from ~/.wrangler/config/default.toml are automatically migrated to the default profile on first use.

kitty_amazing


  • Tests
    • Tests included/updated
    • Tests not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because:

@LukasMurdock LukasMurdock requested a review from a team as a code owner December 31, 2025 23:11
@changeset-bot
Copy link

changeset-bot bot commented Dec 31, 2025

🦋 Changeset detected

Latest commit: 865a239

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant