Docs Menu
Docs Home
/ /
Atlas Device SDKs
/ /

Link User Identities - Node.js SDK

Realm provides many authentication providers to log users into your app. Each provider creates a unique user identity. Realm lets you merge multiple credentials into one user identity.

Consider an application that offers anonymous login. This allows users to explore the app without registering. If users like the application, they create permanent accounts. They sign up with SSO or email/password authentication. By default, this creates a new User object. The app must link the new identity with the original User.

You can link identities using linkCredentials(). This links authentication providers to a logged-in User object.

async function linkAccounts(user, email, password) {
const emailPasswordUserCredentials = Realm.Credentials.emailPassword(
email,
password
);
const linkedAccount = await user.linkCredentials(
emailPasswordUserCredentials
);
return linkedAccount;
}
async function linkAccounts(
user: Realm.User,
email: string,
password: string
) {
const emailPasswordUserCredentials = Realm.Credentials.emailPassword(
email,
password
);
const linkedAccount = await user.linkCredentials(
emailPasswordUserCredentials
);
return linkedAccount;
}

Back

Multi-User Applications

Next

Create & Manage User API Keys