---
title: "Terminal"
source: "https://browserpod.io/docs/reference/Terminal"
---

# Terminal

A handle to a terminal emulator running inside a Pod

A `Terminal` is a handle to a terminal emulator running inside a [Pod](https://browserpod.io/docs/reference/BrowserPod.md). It is created by [`createDefaultTerminal`](https://browserpod.io/docs/reference/BrowserPod/createDefaultTerminal.md) or [`createCustomTerminal`](https://browserpod.io/docs/reference/BrowserPod/createCustomTerminal.md), and passed to [`run`](https://browserpod.io/docs/reference/BrowserPod/run.md) to connect a process to I/O.

```ts
class Terminal {
  write(data: string | Uint8Array): void;
}
```

## Creating a Terminal

- [`createDefaultTerminal`](https://browserpod.io/docs/reference/BrowserPod/createDefaultTerminal.md) creates an [Xterm.js](https://xtermjs.org/)-based terminal attached to a DOM element.
- [`createCustomTerminal`](https://browserpod.io/docs/reference/BrowserPod/createCustomTerminal.md) creates a headless terminal with a custom `onOutput` callback.

## Usage

```ts
const terminal = await pod.createDefaultTerminal(element);
await pod.run("node", ["script.js"], { terminal });
```

## Writing to a terminal

`write` sends text or bytes directly to the terminal’s output, without going through a process in the Pod. Running processes do not receive it as input. Use it to show your own messages alongside program output, such as the command about to run:

```ts
terminal.write("$ npm install\r\n");
await pod.run("npm", ["install"], { terminal });
```
