Skip to main content

Prerequisites

Before this page: understand account conflict resolution. Merging is the recovery path for one specific conflict — a MergeAccountsConfirmationError.
This page covers only the merging case (MergeAccountsConfirmationError). Linking a credential can fail in other ways — the credential already belongs to an account that can’t be merged, or it’s already in use elsewhere. For the full set of conflicts and how to handle each, see account conflict resolution; use this page for the merge path only.

What you’ll build

When a signed-in user adds a credential that already belongs to another mergeable account, verification throws a MergeAccountsConfirmationError. Merging folds that second account into the current one so the user ends up with a single account holding both credentials. Two cases:
  1. No conflicts — the accounts don’t disagree on any profile field. You confirm and merge in one call.
  2. Field-level conflicts — both accounts have a value for the same field (say, a display name). The user picks which value to keep for each field, then you merge.
You’ll build the confirmation UI, the per-field chooser, and the call that completes the merge.
Merging is destructive: the second account is absorbed into the current one. Always confirm with the user before calling mergeUserAccounts — don’t merge automatically on catching the error.

The merge flow

The error carries mergeConflicts. When it’s undefined there’s nothing to resolve — merge directly. When present, it lists each conflicting field with the value held by fromUser (the account being merged in) and currentUser (the signed-in account).

Completing the merge

Handling errors

On success mergeUserAccounts resolves to the merged user and the session updates automatically. Re-render from your auth state (the useUser hook, in the React hooks catalog) rather than the returned value if the rest of your UI already reads from there.

See also

Last modified on July 10, 2026