# Bridge API

> Reference the lower-level bridge that batches commits and dispatches native events.

Canonical: https://natui.dev/docs/api/bridge

`Bridge` connects a renderer to a `Transport`. It owns the operation buffer, live event targets, startup handshake, sequence acknowledgements, and debug request waiters.

### BridgeOptions


| Property | Type | Required | Description |
| --- | --- | --- | --- |
| `requestTimeoutMs` | `number \| undefined` | No | Dump/screenshot reply timeout override (mainly for tests). |

### ReadyInfo


| Property | Type | Required | Description |
| --- | --- | --- | --- |
| `platform` | `string` | Yes |  |
| `protocol` | `number` | Yes |  |

```ts
const bridge = new Bridge(transport, {
  requestTimeoutMs: 10_000,
});
```

Important methods include:

| Method                    | Purpose                                          |
| ------------------------- | ------------------------------------------------ |
| `waitForReady(timeoutMs)` | Await the buffered or future host handshake      |
| `push(op)`                | Buffer one protocol operation                    |
| `flush()`                 | Send one atomic commit                           |
| `sendWindow(props)`       | Configure the native window                      |
| `requestDump()`           | Request the native tree                          |
| `requestScreenshot(path)` | Request a host-rendered PNG                      |
| `emitDebugEvent(...)`     | Synthesize a host event                          |
| `editDebugValue(...)`     | Perform an optimistic host edit                  |
| `quit()`                  | Send the quit message                            |
| `dispose(reason)`         | Reject pending requests and mark the bridge dead |

The reconciler also uses target registration, `latestSeqFor`, and `setPriorityRunner` to dispatch handlers and enforce controlled values.

This is an advanced API. Most applications should use `run`.