Skip to content

Getting user data

You can get information about the current user from the user object in the usePrivy hook:

tsx
const {user} = usePrivy();

For unauthenticated users, the user object will be null. For authenticated users, you can use:

  • user.id to get their Privy DID, which you may use to identify your user on your backend
  • user.created_at to get a UNIX timestamp of when the user was created.
  • user.linked_accounts to get an array of the user's linked accounts

Parsing linked accounts

Each entry in the linked_accounts array has different fields depending on the user data associated with that account type.

See the dropdowns below to see the specific fields associated with each account type.

  AppleAccount
FieldTypeDescription
type'apple_oauth'N/A
emailstringEmail address associated with the user's Apple account.
subjectnumberID of user from Apple's user API.
  CustomJwtAccount
FieldTypeDescription
type'custom_auth'N/A
custom_user_idstringID of user from custom auth provider.
  DiscordAccount
FieldTypeDescription
type'discord_oauth'N/A
subjectstringID of user from Discord user API response.
emailstringEmail of user from Discord user API response
usernamestringUsername of user from Discord user API response. Include the 4-digit discriminator prefixed by '#'.

(See Discord docs)

  EmailAccount
FieldTypeDescription
type'email'N/A
addressstringEmail address of user account.
  FarcasterAccount
FieldTypeDescription
type'farcaster'N/A
fidnumberFID of the user from Farcaster user API response.
owner_address stringWallet address of the user from Farcaster user API response. Note that this is the Farcaster wallet address, and not the Privy embedded wallet address.
usernamestring(Optional) Username of user from Farcaster user API response. Do not include the '@'.
display_namestring(Optional) Display name of user from Farcaster user API response.
biostring(Optional) Bio of user from Farcaster user API response.
profile_picture_urlstring(Optional) Profile picture URL of the user from Farcaster user API response. Must be a valid image URL.
homepage_urlstring(Optional) Profile URL of the user from Farcaster user API response.

(See Farcaster docs. Note that the Privy import interface differs slightly from the Farcaster public interface in order to maintain consistency with other Privy LinkedAccount types.)

  GithubAccount
FieldTypeDescription
type'github_oauth'N/A
subjectstringID of user from GitHub user API response.
emailstringEmail of user from GitHub user API response
namestringName of user from GitHub user API response
usernamestringUsername of user from GitHub user API response

(See GitHub docs)

  GoogleAccount
FieldTypeDescription
type'google_oauth'N/A
subjectstringsub pulled from Google-provided JWT with "openid" scope.
emailstringemail from Google-provided JWT with "email" scope.
namestringname from Google-provided JWT with "profile" scope.
  InstagramAccount
FieldTypeDescription
type'instagram_oauth'N/A
subjectstringID of user from Instagram user API response.
username stringThe name displayed on a user's profile from Instagram's /me API response.

(See Instagram docs)

  LinkedinAccount
FieldTypeDescription
type'linkedin_oauth'N/A
subjectstringID of user from LinkedIn user API response.
email stringEmail of user from LinkedIn user API response
namestringName of user from LinkedIn user API response. Do not include the '@'.

(See Linkedin docs)

  PhoneAccount
FieldTypeDescription
type'phone'N/A
numberstringPhone number of user account (non-international numbers default to US).
  SpotifyAccount
FieldTypeDescription
type'spotify_oauth'N/A
subjectstringID of user from Spotify user API response.
emailstringEmail of user from Spotify user API.
name stringThe name displayed on a user's profile from Spotify display_name API response.

(See Spotify docs)

  TelegramAccount
FieldTypeDescription
type'telegram'N/A
telegram_user_idstringID of a user's telegram account.
first_name stringThe first name displayed on a user's telegram account.
last_name string(Optional) The last name displayed on a user's telegram account.
username string(Optional) The username displayed on a user's telegram account.
photo_url string(Optional) The url of a user's telegram account profile picture.

(See Telegram docs)

  TwitterAccount
FieldTypeDescription
type'twitter_oauth'N/A
subjectstringID of user from Twitter user API response.
name stringName of user from Twitter user API response
usernamestringUsername of user from Twitter user API response. Do not include the '@'.
profile_picture_urlstring(Optional) Profile picture URL of the user from Twitter user API response. Must be a valid image URL.

(See Twitter docs)

  WalletAccount
FieldTypeDescription
type'wallet'N/A
chain_type'ethereum' | 'solana'Type of chain for the wallet. EVM chains ('ethereum') and Solana ('solana') are currently supported.
addressstringChecksummed wallet address.

In addition to the fields outlined above, all linked accounts will have the following metadata:

FieldTypeDescription
first_verified_atnumberUNIX timestamp for when the account was first verified and linked to the user.
latest_verified_atnumberUNIX timestamp for when the account was first verified and linked to the user.