useUserActivityStatus
A hook that returns the localized presence status string for a user — Online when the user is online, a relative "last seen" string (e.g. "Last seen 10 minutes ago") when offline with a valid last_active, or Offline otherwise (including when the user is undefined or the date is unparseable). The relative time is produced through the same getDateString + translation-key pipeline used by message timestamps, so it follows the configured locale.
Best Practices
- Use it to render a user's presence subtitle instead of formatting
online/last_activeyourself. - Customize the "last seen" wording through the
timestamp/UserActivityStatustranslation key, and the static states through theOnline/Offlinekeys. - Treat the returned string as derived UI state.
- Handle an
undefineduser gracefully; the hook returns theOfflinelabel in that case. - Pass a fresh user object so presence changes are reflected.
Parameters
| Parameter | Description | Type |
|---|---|---|
user | The user whose presence status should be resolved. | UserResponse |
Return type
Returns a localized string describing the user's presence status.
| Type |
|---|
string |