> ## Documentation Index
> Fetch the complete documentation index at: https://docs.daily.co/llms.txt
> Use this file to discover all available pages before exploring further.

# useParticipantIds

> useParticipantIds returns a list of participant ids based on optional parameters.

`useParticipantIds(params?): string[];`

Use it to render groups, grids, or lists of participant tiles.

If no parameters are provided, the `id`s of all participants in the call are returned.

## Parameters (optional)

An object with the following properties:

<ParamField body="filter" type="string">
  `'local' | 'remote' | 'screen' | 'owner' | 'record' | FilterParticipantsFunction`, filters the list of participant `id`s according to the provided criteria

  <Expandable title="filter options">
    | Value | Type | Description |
    | :- | :- | - |
    | `'local'` | `string` | Returns only the `local` participant |
    | `'remote'` | `string` | Returns remote participants, everybody but `local` |
    | `'screen'` | `string` | Returns participants with active screen shares |
    | `'owner'` | `string` | Returns participants who joined the call with a meeting token that has the `is_owner` [property](/reference/rest-api/meeting-tokens/create-meeting-token#body-properties-is-owner) set to `true` |
    | `FilterParticipantsFunction` | `Function` | Specifies custom filtering for the list of `id`s. The full Daily [participant object](/reference/daily-js/instance-methods/participants) can be referenced |

    <Note>
      String-based filters can be directly calculated from our internal state store and therefore provide a better render performance than a custom filter that needs to be evaluated at runtime.
    </Note>
  </Expandable>
</ParamField>

<ParamField body="onActiveSpeakerChange" type="Function">
  Callback for the [`active-speaker-change`](/reference/daily-js/events/participant-events#active-speaker-change) event
</ParamField>

<ParamField body="onParticipantJoined" type="Function">
  Callback for the [`participant-joined`](/reference/daily-js/events/participant-events#participant-joined) event
</ParamField>

<ParamField body="onParticipantLeft" type="Function">
  Callback for the [`participant-left`](/reference/daily-js/events/participant-events#participant-left) event
</ParamField>

<ParamField body="onParticipantUpdated" type="Function">
  Callback for the [`participant-updated`](/reference/daily-js/events/participant-events#participant-updated) event
</ParamField>

<ParamField body="sort" type="string">
  `'joined_at' | 'session_id' | 'user_id' | 'user_name' | SortParticipantsFunction`, sorts the list of participant `id`s according to the provided criteria

  <Expandable title="sort options">
    | Value | Type | Description |
    | :- | :- | :- |
    | `'joined_at'` | `string` | Sorts by when participants joined the call in ascending order. |
    | `'session_id'` | `string` | Sorts by participant `session_id`s |
    | `'user_id'` | `string` | Sorts by participant `user_id`s |
    | `'user_name'` | `string` | Sorts in alphabetical order by participant `user_name` |
    | `SortParticipantsFunction` | `Function` | Specifies custom sorting for the list of `id`s. The full Daily [participant object](/reference/daily-js/instance-methods/participants) can be referenced |

    <Note>
      String-based sorting can be directly calculated from our internal state store and therefore provide a better render performance than a custom sort function that needs to be evaluated at runtime.
    </Note>
  </Expandable>
</ParamField>

```json theme={null}
{
  "filter": "remote",
  "onActiveSpeakerChange": <Function>,
  "onParticipantJoined": <Function>,
  "onparticipantUpdated": <Function>,
  "sort": "joined_at",
}
```

## Return value

Returns a `string[]` — an array of participant `id`s.

## Example

```jsx theme={null}
import { useParticipant, useParticipantIds } from '@daily-co/daily-react';
import { useMemo } from 'react';

export const UseParticipantIdsDemo = () => {
  const participantIDs = useParticipantIds({ sort: 'joined_at' });
  const latestParticipantID = useMemo(
    () => participantIDs?.[participantIDs.length - 1],
    [participantIDs]
  );
  const latestParticipant = useParticipant(latestParticipantID);

  return (
    <div>Latest participant: {latestParticipant?.user_name ?? 'none'}</div>
  );
};
```

## See also

<CardGroup>
  <Card title="Hooks" icon="code" iconType="solid">
    * [useParticipant()](/reference/daily-react/use-participant)
    * [useParticipantProperty()](/reference/daily-react/use-participant-property)
    * [useLocalSessionId()](/reference/daily-react/use-local-session-id)
    * [useParticipantCounts()](/reference/daily-react/use-participant-counts)
    * [useActiveParticipant()](/reference/daily-react/use-active-participant)
    * [useActiveSpeakerId()](/reference/daily-react/use-active-speaker-id)
    * [useLocalParticipant()](/reference/daily-react/use-local-participant)
    * [useWaitingParticipants()](/reference/daily-react/use-waiting-participants)
  </Card>

  <Card title="Events" icon="bolt" iconType="solid">
    * [participant-joined](/reference/daily-js/events/participant-events#participant-joined)
    * [participant-left](/reference/daily-js/events/participant-events#participant-left)
    * [participant-updated](/reference/daily-js/events/participant-events#participant-updated)
    * [active-speaker-change](/reference/daily-js/events/participant-events#active-speaker-change)
  </Card>
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.