# useUserPrincipal

`useUserPrincipal` is a convenience hook that returns the signed-in user's
Principal, or `null` while signed out. A signed-out session still holds an
anonymous identity, and the hook does not return its principal.

## Usage

```tsx
import { useUserPrincipal } from "./reactor/hooks"

function UserBadge() {
  const principal = useUserPrincipal()

  if (!principal) return <span>Signed out</span>

  return <span>{principal.toText().slice(0, 12)}...</span>
}
```

## Return Value

| Type                | Description                                                 |
| ------------------- | ----------------------------------------------------------- |
| `Principal \| null` | The signed-in user's Principal, or `null` while signed out. |

## See Also

- [createAuthHooks](https://ic-reactor.b3pay.net/v3/reference/createauthhooks/overview) — Auth hooks factory
- [useAuth](https://ic-reactor.b3pay.net/v3/reference/createauthhooks/useauth) — Main auth hook