# server.Server.watch

- **Module:** server.Server
- **Package:** @libtmux/libtmux
- **Language:** TypeScript
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-ts/blob/2cb93308200da38a26b59876618116850f110607/packages/libtmux/src/server.ts#L338
- **Page:** https://libtmux.org/reference/ts/server-server-watch/

```
server.Server.watch(options: : WatchOptions) -> TmuxEventStream
```

Stream tmux's control-mode notifications until the stream is disposed.

A snapshot answers what is true now; this answers what changed. The stream
holds one `tmux -C attach-session` process for its lifetime, so it reports
events without polling and without a command per read.
That process is a tmux-visible attached client until the stream closes; it
affects client listings, attachment state, hooks, and related policy.

tmux sends a control client no pane output until it attaches, so this
attaches to a session; a server with no sessions has nothing to watch.

Name that session with `target` when reading pane output. Structural
notifications reach the client wherever it attached, but output arrives
only for the attached session, and an untargeted watch lands on whichever
session tmux considers current. With two sessions on the server that is
silence rather than an error.

## Example

```ts
await using events = server.watch();
for await (const event of events) {
  if (event.kind === "window-add") console.log(event.windowId);
}
```
