Skip to main content

useUser

The signed-in person, from the UserInfo response. Null when nobody is signed in.

ComponentReadyView source
Works with
ReactNext.js

Installation​

npm install @lumoauth/react

Usage​

import { useUser } from '@lumoauth/react';

const user = useUser();

Do not decide access from user.roles in the browser alone. Use Protect or the authorization hooks to hide UI, and check again in your API.

The user object​

ReturnsTypeDescription
idstringThe subject of the person (the sub claim).
emailstringThe email address.
emailVerifiedbooleanTrue when the address is verified.
displayNamestringThe name claim, or the first and last name, or the email address.
firstNamestring | undefinedThe given_name claim.
lastNamestring | undefinedThe family_name claim.
avatarUrlstring | undefinedThe picture claim.
mfaEnabledbooleanThe mfa_enabled claim. False when the response does not hold it. LumoAuth does not send it.
rolesstring[]The roles claim, as role identifiers: ROLE_USER, and ROLE_TENANT_ROLE_EDITOR for the role editor. LumoAuth sends it only when the application's token settings have User roles turned on and saved. Empty otherwise.
groupsstring[]The groups claim. Empty when the response does not hold it. LumoAuth does not send it.
claimsRecord<string, unknown>The whole UserInfo response, for custom claims.