---
source_url: https://www.pubnub.com/docs/chat/components/react/custom-hooks/use-user
title: useUser for PubNub Chat Components for React
updated_at: 2026-06-18T11:25:20.693Z
---

> Documentation Index
> For a curated overview of PubNub documentation, see: https://www.pubnub.com/docs/llms.txt
> For the full list of all documentation pages, see: https://www.pubnub.com/docs/llms-full.txt


# useUser for PubNub Chat Components for React

:::warning Migrate to Chat SDK
PubNub will stop supporting Chat Components on January 1, 2025 but you are [welcome to contribute](https://github.com/pubnub/react-chat-components). Learn how to migrate to the Chat SDK [here](https://www.pubnub.com/docs/general/resources/migration-guides/react-components-chat-sdk).
:::

The hook returns metadata for a specified User ID, optionally including its custom data object.

:::note User ID / UUID
User ID is also referred to as **UUID/uuid** in some APIs and server responses but **holds the value** of the **userId** parameter you [set during initialization](https://www.pubnub.com/docs/general/setup/users-and-devices#set-the-user-id).
:::

This hook also sets up a listener that will react to updates of the fetched user. However, this behavior requires a living subscription to the user getting updated - this should be handled by the components.

This hook can be used in order not to fetch data about all users of the application. Instead, only the current user metadata is passed into the `Chat` provider and the `senderInfo` option is enabled on `MessageInput`. This way the information about the senders is attached directly to the messages.

```tsx
const [user, error, isLoading] = useUser({ uuid: "user" });

return (
  <Chat users={[user]}>
    <MessageInput senderInfo={true} />
  </Chat>
);
```

## Input

| Parameter | Defaults | Description |
| --- | --- | --- |
| uuid | String | Optional |  | current User ID | Unique user identifier. If not supplied, the current user's User ID is used. |
| include | Object | Optional |  | n/a | Option to include respective additional fields in the response. |
| → customFields | Boolean | Optional |  | false | Option to fetch custom fields. |

## Output

| Parameter | Description |
| --- | --- |
| `array[0]`Type: User | Metadata of the user. |
| `array[1]`Type: Error | If there's an error fetching the user, it will be available here. |
| `array[2]`Type: Boolean | Indicator that the user data is still being loaded. |