# getTextTracks

The text tracks a filter or track definition matches, from the media or the app

## Import

```tsx
import { getTextTracks } from '@videojs/react';
```

`getTextTracks` returns the tracks in `textTrackList` that a filter or [track definition](https://videojs.org/docs/framework/react/reference/api/define-text-track) matches, from the media and the app alike. Each track’s `source` says which. The list comes from the [text track feature](https://videojs.org/docs/framework/react/reference/api/feature-text-tracks).

A filter picks tracks by `kind`, `label`, or `language`, or with a function. Each given field must match, and a list of kinds matches any kind in it. Without a filter, `getTextTracks` returns every track.

## Usage

In a component, [`useTextTracks`](https://videojs.org/docs/framework/react/reference/api/use-text-tracks) re-renders when the tracks change. `getTextTracks` reads them once, such as in an event handler. Pass it a store typed with your player’s features, such as the one the preset’s `usePlayer` returns:

```tsx
import { getTextTracks } from '@videojs/react';
import { usePlayer } from '@videojs/react/video';

function LogChaptersButton() {
  const store = usePlayer();

  return <button onClick={() => console.log(getTextTracks(store, { kind: 'chapters' }))}>Log chapter tracks</button>;
}
```

## API Reference

`getTextTracks(source, filter?): MediaTextTrack[]`

### Parameters

| Parameter | Type | Default | Description |
| --- | --- | --- | --- |
| `source` (required) | `{ textTrackList: readonly MediaTextTrack[] }` | — | State that lists text tracks, such as the player store. |
| `filter` | `{ kind?: TextTrackKind \| readonly TextTrackKind[]; label?: string; language?: string } \| ((track: MediaTextTrack) => boolean) \| { kind: 'subtitles' \| 'captions' \| 'descriptions' \| 'chapters' \| 'metadata'; label?: string; language?: string; schema?: StandardSchemaV1 }` | `{}` | Picks tracks by kind, label, or language, or with a function. Defaults to every track. |

### Return Value

`MediaTextTrack[]`

---

React documentation: https://videojs.org/docs/framework/react/llms.txt
All documentation: https://videojs.org/llms.txt
