Skip to main content

useUser()

The useUser composable returns the currently authenticated user object as a reactive computed ref. It is auto-imported and available everywhere without an explicit import.

Usage

pages/profile.vue
<script setup lang="ts">
const user = useUser()
</script>

<template>
<div v-if="user">
<h1>{{ user.displayName }}</h1>
<p>{{ user.email }}</p>
</div>
<p v-else>Not signed in.</p>
</template>

Return Value

useUser() returns a ComputedRef<User | null>. The value is null when no user is authenticated.

User Object

PropertyTypeDescription
substringThe user's unique subject identifier
displayNamestring | nullThe user's display name
emailstring | nullThe user's email address
firstNamestring | nullThe user's first name
lastNamestring | nullThe user's last name
profileUrlstring | nullURL to the user's profile picture

Notes

  • This composable is re-exported from @thunderid/vue and behaves identically in Nuxt.
  • On an SSR-rendered page, the user value is hydrated from the server session and available on first render without a client-side fetch.
  • Use useThunderID() if you also need access to auth methods (signIn, signOut, etc.).
ThunderID LogoThunderID Logo

Product

DocsAPIsSDKs
© WSO2 LLC. All rights reserved.Privacy PolicyCookie Policy