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_active yourself.
  • Customize the "last seen" wording through the timestamp/UserActivityStatus translation key, and the static states through the Online / Offline keys.
  • Treat the returned string as derived UI state.
  • Handle an undefined user gracefully; the hook returns the Offline label in that case.
  • Pass a fresh user object so presence changes are reflected.

Parameters

ParameterDescriptionType
userThe user whose presence status should be resolved.UserResponse

Return type

Returns a localized string describing the user's presence status.

Type
string