What it does
stack swap <from> <to> replaces one provider with
another in the same category by setting up the destination first, then
attempting aliases and local cleanup of the source. It does not delete the
old upstream resource or provide an atomic whole-swap guarantee. Inspect
partial failures and remaining configuration or secrets.
Any two registered providers in the same category can be swapped; Stack
refuses a swap across categories. Separately, the source registers 20
provider pairs (40 one-way entries, both directions) across six categories
in packages/core/src/swap.ts. A registered pair supplies any
env-key aliases for that direction. If you pick a destination with no
registered pair, Stack warns, lists the registered destinations for
from, and continues without aliases.
| Category | Registered pairs (both directions) |
|---|---|
| Auth | clerk ↔ auth0, clerk ↔ workos, auth0 ↔ workos |
| Database | supabase ↔ neon |
| resend ↔ sendgrid, resend ↔ mailgun, resend ↔ postmark, sendgrid ↔ mailgun, sendgrid ↔ postmark, mailgun ↔ postmark | |
| Analytics | posthog ↔ mixpanel, posthog ↔ plausible, mixpanel ↔ plausible |
| Observability | datadog ↔ grafana |
| Deploy | vercel ↔ railway, vercel ↔ fly, vercel ↔ render, railway ↔ fly, railway ↔ render, fly ↔ render |
Basic usage
# Migrate from Clerk to Auth0
stack swap clerk auth0
# Preview the plan without executing
stack swap clerk auth0 --dry-run What happens under the hood:
- Stack checks that both names are known providers in the same category and that
fromis configured in.stack.toml. - Stack prints the plan. With
--dry-runit stops here. - Stack runs provider setup for
to; authentication and resource operations depend on that adapter and its configured credentials. - Stack attempts any env-key aliases registered for the pair.
- Unless
--keep-fromis set, Stack attempts Phantom secret cleanup and removes the localfromservice/MCP entry. The old upstream resource is kept; secrets can remain when terminal confirmation is unavailable or refused. - Local configuration updates can be partial. A source-cleanup failure does not revert the destination setup; review warnings and finish cleanup manually.
Env-key aliases
Some pairs use different env variable names for the same concept. For
example, Supabase writes SUPABASE_URL while Neon writes
DATABASE_URL. After a supabase → neon swap, Stack
attempts to mirror DATABASE_URL into
SUPABASE_URL in Phantom. In this source only the
supabase ↔ neon pairs register aliases. Phantom does not hand stored
values to Stack, so a mirror can be refused; Stack then prints the
phantom add step for the alias. Inspect warnings and
configure the required value yourself through Phantom's trusted-terminal
flow.
Flags
| Flag | Behaviour |
|---|---|
--dry-run | Print every step that would run without making any upstream API calls or writing any files. |
--keep-from | Provision to without removing from. Useful for a side-by-side migration where you want to validate the new provider before cutting over. |
--no-rollback | Accepted by this source, but not used or forwarded by the swap implementation. It does not disable the destination add workflow's failure cleanup. |
Rollback on failure
If destination setup fails after creating a resource, the add workflow attempts cleanup, including upstream teardown only when the provider supports it. Vault removal and teardown can fail or leave secrets stored; inspect the reported partial failure. Source removal begins only after destination setup succeeds, and later cleanup failure does not undo that success. See Transactional rollback for the full failure-handling model.
Inspect available options
# Inspect the options supported by your installed CLI
stack swap --help