Skip to content

Getting user data ‚Äč

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

const {user} = usePrivy();

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

  • to get their Privy DID, which you may use to identify your user on your backend
  • user.createdAt to get a JavaScript Date object of when the user was created

The user object also contains information about all of the accounts a user has linked with Privy. Use the fields:

  • to get the user's Apple account
  • user.discord to get the user's Discord account
  • to get the user's email account
  • user.github to get the user's Github account
  • to get the user's Google account
  • user.instagram to get the user's Instagram account
  • user.linkedin to get the user's Linkedin account
  • to get the user's phone (SMS) number
  • user.spotify to get the user's Spotify account
  • user.tiktok to get the user's TikTok account
  • user.twitter to get the user's Twitter account
  • user.wallet to get the user's Ethereum wallet (crypto account)

If a user has not linked an account of a given type, the corresponding field on the user object will be undefined.

Different account types contain different information about the underlying account. For example, you might use user.wallet.address to get a user's Ethereum address and user.discord.username to get a user's Discord username.

Alternatively, you can also get a list of all the accounts a user has linked with Privy via user.linkedAccounts. Each account in this list is additionally annotated with a type field that denotes the type of account ('email', 'phone', 'wallet', etc.).