useUser
The signed-in person, from the UserInfo response. Null when nobody is signed in.
Installation
- npm
- pnpm
- Yarn
- Bun
npm install @lumoauth/react
pnpm add @lumoauth/react
yarn add @lumoauth/react
bun add @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
| Returns | Type | Description |
|---|---|---|
id | string | The subject of the person (the sub claim). |
email | string | The email address. |
emailVerified | boolean | True when the address is verified. |
displayName | string | The name claim, or the first and last name, or the email address. |
firstName | string | undefined | The given_name claim. |
lastName | string | undefined | The family_name claim. |
avatarUrl | string | undefined | The picture claim. |
mfaEnabled | boolean | The mfa_enabled claim. False when the response does not hold it. LumoAuth does not send it. |
roles | string[] | 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. |
groups | string[] | The groups claim. Empty when the response does not hold it. LumoAuth does not send it. |
claims | Record<string, unknown> | The whole UserInfo response, for custom claims. |