useUser()
The useUser()
hook is a convenient way to access the current user's User
object, which holds all of the information for a single user of your application and provides a set of methods to manage their account. This hook also provides boolean values to check if the user is signed in and if Clerk has loaded and initialized.
useUser()
returns
- Name
isSignedIn
- Type
boolean
- Description
A boolean that returns
true
if the user is signed in.
- Name
isLoaded
- Type
boolean
- Description
A boolean that until Clerk loads and initializes, will be set to
false
. Once Clerk loads,isLoaded
will be set totrue
.
- Name
user
- Type
User
- Description
The
User
object for the currently active user. If the user is not signed in,user
will benull
.
How to use the useUser()
hook
Retrieve the current user data with the useUser()
hook
The following example demonstrates how to use the useUser()
hook to access the user
object, which includes the current user's data, like the user's full name. The isLoaded
and isSignedIn
properties are used to handle the loading state and to check if the user is signed in, respectively.
For more information on the User
object, see the reference
.
Update the current user data with the useUser()
hook
The following example demonstrates how to use the useUser()
hook to access the user
object, which includes the update
method for updating the user's data.
For more information on the update()
method, see the User
reference.
Reload user data with the useUser()
hook
To retrieve the latest user data after updating the user elsewhere, use the user.reload()
method.
For more information on the reload()
method, see the User
reference.
Feedback
Last updated on