User Management

How to manage your authenticated user in React Native

Get Current User

Once your user has been authenticated, you can call Passage.getCurrentUser() which will return a PassageUser object. When the user is no longer authenticated, this method will return null.

Here's an example:

const user: <PassageUser | null> = await passage.getCurrentUser();
if (user) {
  console.log(`User ID: ${}`);
} else {
  console.log('No authenticated user');

You can find all of the available properties on PassageUser here.

Methods for updating user

Change contact info

To change the user's phone number or email, you can follow the examples below. Note that the user will receive a verification message where they'll need to confirm the change.

// Change email for authenticated user
const newEmail = '[email protected]';
await passage.changeEmail(newEmail);

// Change phone for authenticated user
const newPhone = '155555555555';
await passage.changePhone(newPhone);

Manage user passkeys

The following CRUD operations are available for authenticated user passkeys. Note that each of these methods could throw an error that you'd need to handle.

// List user's passkeys
const user = await passage.getCurrentUser();
const userPasskeys = user?.webauthnDevices || [];

// Create a new passkey
const newPasskey = await passage.addPasskey();

// Edit name of passkey
const passkeyId = 'XXXXXXXXXXXXXX';
const passkeyNewName = 'My favorite passkey';
await passage.editPasskeyName(passkeyId, passkeyNewName);

// Delete/revoke a passkey
await passage.deletePasskey(passkeyId);

Sign out user

To sign out your user and remove their tokens from the user's device (more on this in the next section), you can simply call Passage.signOut() .

await passage.signOut();

Last updated