User Management
Managing the current user
Overview
0xPass provides a simple way to authenticate and manage any information tied to the current user.
The useUser
hook provides all contextual information on the user:
Note:
User object is ONLY created for authenticated or verified users. These are users
that Sign In With Ethereum. The user object is null for unauthenticated users.
Usage
Import the useUser
into your component
import { useUser } from "0xpass"
Use in the code
const { user } = useUser()
You can later access user identities as follows
<p> User's Twitter Username: {user.twitter.screen_name} </p>
Properties
useUser()
returns several usable properties. Below is the exhaustive list:
Example on how to capture a specific property from useUser()
const { user, getAccessToken } = useUser()
Property | Usage | Detailed Guide |
---|---|---|
user | Provides contexual information about userr | User-Entity |
login | Function used to login user | - |
logout | Function used to logout user | - |
getAccessToken | Get Access Token for user (async) | Access Token |
isAuthenticated | Boolean (is user authenticated?) | - |
isLoading | Boolean (is something in transit) | - |
linkGoogle | Link Google account | Social Accounts |
linkFarcaster | Link Farcaster account | Social Accounts |
linkTwitter | Link Twitter account | Social Accounts |
unlinkGoogle | Unlink Google account | Social Accounts |
unlinkFarcaster | Unlink Farcaster account | Social Accounts |
unlinkTwitter | Unlink Twitter account | Social Accounts |