Docs Menu

Link User Identities

Realm provides multiple ways for users to log into your application. Because each method of authentication corresponds to a unique user identity, Realm lets you merge multiple identities belonging to a single user into one user identity.

Consider an application that enables users to authenticate via anonymous authentication. When that user decides to create a full account with an SSO provider or email/password authentication, you need some way of persisting the user's original anonymous identity with their new permanent identity.

You can link identities using the linkCredentials() method of the User object of a logged-in User.

async function linkAccounts(user, email, password) {
const emailPasswordUserCredentials = Realm.Credentials.emailPassword(
await user.linkCredentials(emailPasswordUserCredentials);
return user;
←  Call a FunctionAPI Reference - Web SDK →
Give Feedback
© 2022 MongoDB, Inc.


  • Careers
  • Investor Relations
  • Legal Notices
  • Privacy Notices
  • Security Information
  • Trust Center
© 2022 MongoDB, Inc.