Skip to main content

Introduction

When a user authenticates with Dynamic, they may use various methods such as email, social login, passkey, or connecting a wallet. Understanding which method they used - and which one was used most recently - is essential for building personalized experiences and implementing proper session management. This guide shows you how to:
  1. Find the user’s last used login method
  2. Check all available verified credentials
  3. Determine the type and provider of each credential

Finding the Last Used Login Method

Every user has a lastVerifiedCredentialId property that points to the credential they most recently used to authenticate. You can use this ID to look up the credential in the verifiedCredentials array.
React Native
import { dynamicClient } from '<path to client file>';

const checkLastLoginMethod = () => {
  const user = dynamicClient.auth.authenticatedUser;

  // Get the last verified credential ID
  const lastCredentialId = user?.lastVerifiedCredentialId;

  // Find the credential in the verifiedCredentials array
  const lastCredential = user?.verifiedCredentials?.find(
    (vc) => vc.id === lastCredentialId
  );

  if (!lastCredential) {
    console.log('No verified credentials found');
    return null;
  }

  // Check the credential type (format)
  console.log('Credential format:', lastCredential.format);
  // Possible values: 'blockchain', 'email', 'oauth', 'passkey'

  // For wallet credentials, check the provider
  if (lastCredential.format === 'blockchain') {
    console.log('Wallet provider:', lastCredential.walletProvider);
    // Possible values: 'browserExtension', 'embeddedWallet', 'walletConnect', etc.
  }

  // For OAuth credentials, check the provider
  if (lastCredential.format === 'oauth') {
    console.log('OAuth provider:', lastCredential.oauthProvider);
  }

  return lastCredential;
};

Credential Types (Format)

The format field on a verified credential indicates what type of authentication method was used:
FormatDescription
blockchainUser authenticated by signing a message with a blockchain wallet
emailUser authenticated via email (OTP or magic link)
oauthUser authenticated via a social provider (Google, Apple, Discord, etc.)
passkeyUser authenticated using a passkey (WebAuthn)

Wallet Provider Types

When a credential has a format of blockchain, the walletProvider field indicates what type of wallet was used:
Wallet ProviderDescription
browserExtensionBrowser extension wallet (MetaMask, Coinbase Wallet extension, etc.)
embeddedWalletDynamic’s embedded wallet
walletConnectWallet connected via WalletConnect protocol
qrCodeWallet connected by scanning a QR code
deepLinkWallet connected via deep link (mobile)
custodialServiceCustodial wallet service
smartContractWalletSmart contract wallet (account abstraction)

OAuth Provider Types

When a credential has a format of oauth, the oauthProvider field indicates which social provider was used:
OAuth ProviderDescription
googleGoogle account
appleApple ID
discordDiscord account
twitterTwitter/X account
githubGitHub account
facebookFacebook account
twitchTwitch account
linkedinLinkedIn account
microsoftMicrosoft account
farcasterFarcaster account
telegramTelegram account
See the full list of supported social providers in Social Providers.

Iterating Through All Credentials

You can also iterate through all of a user’s verified credentials to understand their full authentication history:
React Native
import { dynamicClient } from '<path to client file>';
import { View, Text } from 'react-native';

const AllCredentials = () => {
  const user = dynamicClient.auth.authenticatedUser;

  return (
    <View>
      {user?.verifiedCredentials?.map((vc) => (
        <View key={vc.id}>
          <Text>Format: {vc.format}</Text>
          <Text>Identifier: {vc.publicIdentifier}</Text>
          {vc.format === 'blockchain' && (
            <Text>Wallet Provider: {vc.walletProvider}</Text>
          )}
          {vc.format === 'oauth' && (
            <Text>OAuth Provider: {vc.oauthProvider}</Text>
          )}
          {vc.id === user.lastVerifiedCredentialId && (
            <Text>(Last used)</Text>
          )}
        </View>
      ))}
    </View>
  );
};

Determining Login Method Type with Helper Functions

Here’s a helper function pattern you can use to easily determine the login method type:

Verified Credentials

Learn more about the verified credential structure and all available fields

Accessing Users

Different ways to access user information in your application