# server.Server.connect

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

```
server.Server.connect(options: : ConnectOptions) -> Promise<ConnectedServer>
```

Bind this server to one control-mode connection and return it.

The returned server has the same API and shares one control connection for
events and daemon-lifetime tracking. Commands use ordinary tmux processes:
control mode cannot frame arbitrary command output truthfully when aliases
and waiting commands are allowed.
The connection has the attached-client lifecycle described by
{@link watch} until it closes.

Each snapshot acquisition remains one atomic tmux invocation containing
its daemon identity read and all four listings. The first connected
snapshot also follows the observer authentication and version probes.

## Example

```ts
await using live = await server.connect();
for await (const event of live.subscribe()) {
  if (event.kind === "window-add") console.log((await live.snapshot()).windows.count());
}
```
