# selection.Selection.first

- **Module:** selection
- **Package:** libtmux
- **Language:** TypeScript
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-ts/blob/073b9d7dedad900bff6f5ec0ea47794e40225870/packages/libtmux/src/selection.ts#L528
- **Page:** https://libtmux.org/en/ts/latest/reference/selection-selection-first/

```
first(criteria?: WhereOf<Model>): Model | undefined
```

The first member, or the first matching `criteria`.

Answers undefined for no match. Use this when zero is an ordinary outcome;
use [`one`](/en/ts/latest/reference/selection-selection-one/) when it is not.

## Examples

```ts
snapshot.windows.first({ name: "editor" })?.id;
```

## Type parameters

- [`Model`](/en/ts/latest/reference/selection-selection/#selection.Selection.type-parameter.Model), declared by [`Selection<Model>`](/en/ts/latest/reference/selection-selection/)

## Parameters

- `criteria?` (`WhereOf<Model>`)

## Guides

Pages that discuss `first`.

- [Filtering and queries](/en/ts/latest/concepts/queries/)
