useUsers for PubNub Chat Components for React

The hook returns a list of UUID metadata objects, optionally including the custom data object for each.

Pagination is handled internally. You can adjust the limit of returned users on a single call (max/default 100) and call a function returned by the hook to get another page of results. This hook also sets up a listener that will react to updates and removals of already fetched users. However, this behavior requires a living subscription to users getting updated - this should be handled by the components.

const [users, fetchPage, total, error] = useUsers();

return <Chat users={users}>{/* Add components here */}</Chat>;


includeObjectOptionaln/aOption to include respective additional fields in the response.
 customFieldsBooleanOptionalfalseOption to fetch custom fields.
filterStringOptionaln/aExpression used to filter the results. Only objects whose properties satisfy the given expression are returned. See the Objects Filtering Language Definition for more details.
sortObjectOptionaln/aKey-value pair of a property to sort by and a sort direction.

Available options are id, name, and updated.

Use asc or desc to specify sort direction, or specify null to take the default sort direction (ascending).

Example: {name: 'asc'}
limitNumberOptional100Number of objects to return in response.

Default is 100 which is also the maximum value.


array[0]User[]List of returned users.
array[1]FunctionFunction that can be called to fetch another page of users.
array[2]NumberTotal number of stored users.
array[3]ErrorIf there's an error fetching users, it will be available here.
On this page