⏻
HELGE SVERREAll-stack Developer
Bergen, Norway • v13.0
est. 2012  |  197 repos  |  12.8k+ contributions
Tools  |   Theme:
Vapor Swap: Account Switcher for a Server-Side Rendering Dinosaur
October 23, 2026

TL;DR

Vapor Swap works like nvm, but for accounts. You keep a list of profiles, and when you move into a project that deploys to a different account, you run vapor-swap swap accountname and your vapor deploy production is already authed.

Is it overkill and entirely unnecessary? Yes. Do I probably have 3 Vapor accounts I need to regularly swap between? Also yes. But the problem existed. I murdered the problem. No problem, no moo.

Why not just edit config.json?

Taylor Otwell says Laravel Vapor is "not dying", and I still deploy client projects to three different Vapor accounts. The Vapor CLI keeps one token in ~/.laravel-vapor/config.json, and that file is shared by every terminal. Switch it to deploy client A, and the terminal where you were about to deploy client B is now pointed at client A too.

Vapor Swap keeps the account per terminal instead:

vapor-swap add work                  # Save a profile: prompts for a token and team
vapor-swap swap work                 # Use it in this terminal only
vapor deploy production              # Deploys with the work token
vapor-swap swap personal --sticky    # Make personal the default for new terminals

Install

composer global require helgesverre/vapor-swap

If vapor-swap isn't found afterwards, add the directory from composer global config bin-dir --absolute to your PATH. Then add the shell integration to your shell config:

# ~/.zshrc
eval "$(vapor-swap init zsh)"

# ~/.bashrc
eval "$(vapor-swap init bash)"

# ~/.config/fish/config.fish
vapor-swap init fish | source

It needs PHP 8.2 or later and the Vapor CLI.

How it works

Profiles live in ~/.vapor-swap/config.json, one API token and team per name. vapor-swap swap work writes a temporary config to ~/.vapor-swap/sessions/, made from the profile merged with your normal Vapor config, and sets VAPOR_API_TOKEN, VAPOR_SWAP_SESSION and VAPOR_SWAP_PROFILE in the current shell. The shell integration wraps the vapor command so it uses that session when there is one and your global config when there isn't. Other terminals don't see any of it.

--sticky writes the profile to ~/.laravel-vapor/config.json itself, so it becomes the default for every new terminal.

Call vapor, not vendor/bin/vapor: the wrapper only catches the bare command.

Tokens are stored as plaintext with 0600 permissions, the same way Vapor stores its own. Removing a profile doesn't revoke the token.

Everyday use

vapor-swap add agency --token tk_xyz789 --team 12345
vapor-swap list                      # Saved profiles
vapor-swap current                   # Account and team in this terminal
vapor-swap swap agency
vapor deploy production              # Other terminals keep their account
vapor-swap reset                     # Back to the default
vapor-swap remove old-client

The tests run on PHPUnit with PHP 8.2–8.5 on Linux, plus macOS and Windows jobs, using throwaway home directories, fake credentials and the real Vapor CLI.




<!-- generated with nested tables and zero regrets -->