# @mwillbanks/tuil-ghostty-web

Source: /tuil/docs/reference/packages/ghostty-web
Locale: en

Browser adapter that runs existing TUIL Ink applications inside Ghostty Web.



## Overview [#overview]

Browser adapter that runs existing TUIL Ink applications inside Ghostty Web.

`@mwillbanks/tuil-ghostty-web` is independently installable and also participates in the
umbrella `@mwillbanks/tuil` runtime where applicable.

## Installation [#installation]

<CodeBlockTabs defaultValue="npm">
  <CodeBlockTabsList>
    <CodeBlockTabsTrigger value="npm">
      npm
    </CodeBlockTabsTrigger>

    <CodeBlockTabsTrigger value="pnpm">
      pnpm
    </CodeBlockTabsTrigger>

    <CodeBlockTabsTrigger value="yarn">
      yarn
    </CodeBlockTabsTrigger>

    <CodeBlockTabsTrigger value="bun">
      bun
    </CodeBlockTabsTrigger>
  </CodeBlockTabsList>

  <CodeBlockTab value="npm">
    ```bash
    npm install @mwillbanks/tuil-ghostty-web
    ```
  </CodeBlockTab>

  <CodeBlockTab value="pnpm">
    ```bash
    pnpm add @mwillbanks/tuil-ghostty-web
    ```
  </CodeBlockTab>

  <CodeBlockTab value="yarn">
    ```bash
    yarn add @mwillbanks/tuil-ghostty-web
    ```
  </CodeBlockTab>

  <CodeBlockTab value="bun">
    ```bash
    bun add @mwillbanks/tuil-ghostty-web
    ```
  </CodeBlockTab>
</CodeBlockTabs>

## How it operates [#how-it-operates]

The optional browser adapter connects the existing Ink runtime to Ghostty Web through bounded TTY streams, ordered output, input forwarding, resize events, and a semantic DOM companion.

<Mermaid
  chart="flowchart LR
  S0[&#x22;lazy WASM initialization&#x22;]
  S1[&#x22;terminal mount&#x22;]
  S2[&#x22;stream bridge&#x22;]
  S3[&#x22;resize and input&#x22;]
  S4[&#x22;deterministic disposal&#x22;]
  S0 --> S1
  S1 --> S2
  S2 --> S3
  S3 --> S4"
/>

## API [#api]

| API                                                                                                                 | Signature                                   | Description                                       |
| ------------------------------------------------------------------------------------------------------------------- | ------------------------------------------- | ------------------------------------------------- |
| [`createTuilGhosttyDocumentApp`](/tuil/docs/reference/packages/ghostty-web/api/create-tuil-ghostty-document-app)         | `export createTuilGhosttyDocumentApp`       | Public export createTuilGhosttyDocumentApp.       |
| [`createTuilGhosttyDocumentSession`](/tuil/docs/reference/packages/ghostty-web/api/create-tuil-ghostty-document-session) | `export createTuilGhosttyDocumentSession`   | Public export createTuilGhosttyDocumentSession.   |
| [`createTuilGhosttyFeasibilityApp`](/tuil/docs/reference/packages/ghostty-web/api/create-tuil-ghostty-feasibility-app)   | `export createTuilGhosttyFeasibilityApp`    | Public export createTuilGhosttyFeasibilityApp.    |
| [`createTuilGhosttyStoryApp`](/tuil/docs/reference/packages/ghostty-web/api/create-tuil-ghostty-story-app)               | `function createTuilGhosttyStoryApp`        | Public function createTuilGhosttyStoryApp.        |
| [`generatePlaygroundTsx`](/tuil/docs/reference/packages/ghostty-web/api/generate-playground-tsx)                         | `export generatePlaygroundTsx`              | Public export generatePlaygroundTsx.              |
| [`initializeTuilGhostty`](/tuil/docs/reference/packages/ghostty-web/api/initialize-tuil-ghostty)                         | `function initializeTuilGhostty`            | Public function initializeTuilGhostty.            |
| [`mountTuilGhostty`](/tuil/docs/reference/packages/ghostty-web/api/mount-tuil-ghostty)                                   | `function mountTuilGhostty`                 | Public function mountTuilGhostty.                 |
| [`playgroundComponentCatalog`](/tuil/docs/reference/packages/ghostty-web/api/playground-component-catalog)               | `export playgroundComponentCatalog`         | Public export playgroundComponentCatalog.         |
| [`PlaygroundDocumentV1`](/tuil/docs/reference/packages/ghostty-web/api/playground-document-v1)                           | `export PlaygroundDocumentV1`               | Public export PlaygroundDocumentV1.               |
| [`PlaygroundNodeV1`](/tuil/docs/reference/packages/ghostty-web/api/playground-node-v1)                                   | `export PlaygroundNodeV1`                   | Public export PlaygroundNodeV1.                   |
| [`TuilGhosttyAccessibilityOptions`](/tuil/docs/reference/packages/ghostty-web/api/tuil-ghostty-accessibility-options)    | `interface TuilGhosttyAccessibilityOptions` | Public interface TuilGhosttyAccessibilityOptions. |
| [`TuilGhosttyInstance`](/tuil/docs/reference/packages/ghostty-web/api/tuil-ghostty-instance)                             | `interface TuilGhosttyInstance`             | Public interface TuilGhosttyInstance.             |
| [`TuilGhosttyMountOptions`](/tuil/docs/reference/packages/ghostty-web/api/tuil-ghostty-mount-options)                    | `interface TuilGhosttyMountOptions`         | Public interface TuilGhosttyMountOptions.         |
| [`TuilGhosttyStoryOptions`](/tuil/docs/reference/packages/ghostty-web/api/tuil-ghostty-story-options)                    | `interface TuilGhosttyStoryOptions`         | Public interface TuilGhosttyStoryOptions.         |
| [`TuilGhosttyTerminalOptions`](/tuil/docs/reference/packages/ghostty-web/api/tuil-ghostty-terminal-options)              | `interface TuilGhosttyTerminalOptions`      | Public interface TuilGhosttyTerminalOptions.      |
| [`validatePlaygroundDocument`](/tuil/docs/reference/packages/ghostty-web/api/validate-playground-document)               | `export validatePlaygroundDocument`         | Public export validatePlaygroundDocument.         |

## Events and lifecycle [#events-and-lifecycle]

Ghostty input enters the existing Ink input pipeline. Output and lifecycle failures reach the owning TUIL error boundary.

All subscriptions and registrations return a disposer or belong to an owning
runtime that disposes them in reverse order.

## Example [#example]

```tsx
import { mountTuilGhostty } from "@mwillbanks/tuil-ghostty-web";

const terminal = await mountTuilGhostty({ app, element });
await terminal.unmount();
```

## Related [#related]

* [Package architecture](/tuil/docs/concepts/packages)
* [Events](/tuil/docs/concepts/events)
* [Testing](/tuil/docs/guides/testing)
