useUser()
The useUser()
composable provides access to the current user's User
object, which contains all the data for a single user in your application and provides methods to manage their account. This composable also allows you to check if the user is signed in and if Clerk has loaded and initialized.
Returns
- Name
isLoaded
- Type
Ref<boolean>
- Description
A boolean that indicates whether Clerk has completed initialization. Initially
false
, becomestrue
once Clerk loads.
- Name
user
- Type
Ref<User>
- Description
The
User
object for the current active user. If the user isn't signed in,user
will benull
.
- Name
isSignedIn
- Type
Ref<boolean>
- Description
How to use the useUser()
composable
Get the current user
The following example uses the useUser()
composable to access the User
object, which contains the current user's data such as their full name. The isLoaded
and isSignedIn
properties are used to handle the loading state and to check if the user is signed in, respectively.
Update user data
The following example uses the useUser()
composable to access the User
object, which calls the update()
method to update the current user's information.
Reload user data
The following example uses the useUser()
composable to access the User
object, which calls the reload()
method to get the latest user's information.
Feedback
Last updated on