The useUser() composable provides access to the current user's UserJavaScript Icon 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.
The following example uses the useUser() composable to access the UserJavaScript Icon 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.
The following example uses the useUser() composable to access the UserJavaScript Icon object, which calls the update()JavaScript Icon method to update the current user's information.
The following example uses the useUser() composable to access the UserJavaScript Icon object, which calls the reload()JavaScript Icon method to get the latest user's information.
You only need to call user.reload() if you've updated the User object outside of the user.update() method or Clerk hooks; for example, if you made changes through an API endpoint.
ReloadUser.vue
<scriptsetup>import { useUser } from'@clerk/vue'const { isLoaded,user } =useUser()constupdateUser=async () => {// Update user data via an API endpointconstupdateMetadata=awaitfetch('/api/updateMetadata')// Check if the update was successfulif (updateMetadata.message !=='success') {thrownewError('Error updating') }// If the update was successful, reload the user dataawaituser.value?.reload()}</script><template> <divv-if="!isLoaded"><!-- Handle loading state --> </div> <divv-else-if="user"> <button@click="updateUser">Update your metadata</button> <p>user role: {{ user.publicMetadata?.role }}</p> </div></template>