# session.Session.newWindow

- **Module:** session
- **Package:** libtmux
- **Language:** TypeScript
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-ts/blob/073b9d7dedad900bff6f5ec0ea47794e40225870/packages/libtmux/src/session.ts#L366
- **Page:** https://libtmux.org/en/ts/latest/reference/session-session-newwindow/

```
newWindow(options?: NewWindowOptions): Promise<Window>
```

Create a window in this session and resolve it as a handle.

The handle costs a snapshot of the whole server, not of this session: a
window made here is linked into every session grouped with it, and the
handle reports those links. When the id is enough,
`server.pipeline([session.plan.newWindow().`[`argv`](/en/ts/latest/reference/types-plannedoperation-argv/)`])` returns it for one
command, whatever the server's size.

`index` selects an exact slot. An occupied slot fails without replacing
its window; omitting `index` leaves placement to tmux.

## Examples

```ts
const created = await session.newWindow({ index: 3, name: "editor" });
created.name; // "editor"
created.index; // 3
```

## Parameters

- `options?` (`NewWindowOptions`)

## Raises

- [`TypeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError): when `index` is outside 0 through 2147483647, is not an integer, or is combined with `direction`.

## tmux command

The tmux commands behind `newWindow`.

- [`new-window`](/en/tmux/latest/manual/new-window/)

## tmux C API

The C declarations in tmux that implement these commands.

- [`cmd_new_window_entry`](/en/tmux/latest/reference/c-variable-cmd_new_window_entry/) (attribute)
- [`cmd_new_window_exec`](/en/tmux/latest/reference/c-function-cmd-new-window-c-cmd_new_window_exec/) (function)

## Guides

Pages that discuss `newWindow`.

- [Control mode vs one-shot](/en/ts/latest/concepts/transports/)

## In other ports

Create a window

| Language | Equivalent |
| --- | --- |
| Python | [`libtmux.Session.new_window`](/en/py/latest/reference/libtmux-session-new_window/) (method) |
| Ruby | [`LibTmux::Session#new_window`](/en/ruby/latest/reference/libtmux-session-new_window/) (method) |
| Lua | [`libtmux.Session:new_window`](/en/lua/latest/reference/libtmux-session-new_window/) (method) |
| Rust | [`session.Session.new_window`](/en/rs/latest/reference/session-session-new_window/) (method) |
| Go | [`tmux.Session.NewWindow`](/en/go/latest/reference/tmux-session-newwindow/) (method) |
| Java | [`io.github.libtmux.Session.newWindow`](/en/java/latest/reference/io-github-libtmux-session-session-newwindow/) (method) |
| Kotlin | [`io.github.libtmux.kotlin.Session.newWindow`](/en/kotlin/latest/reference/io-github-libtmux-kotlin-session-newwindow/) (method) |
| Scala | [`io.github.libtmux.scaladsl.Session.newWindow`](/en/scala/latest/reference/io-github-libtmux-scaladsl-session-newwindow/) (method) |
| C# | [`LibTmux.Session.CreateWindowAsync`](/en/csharp/latest/reference/libtmux-session-createwindowasync/) (method) |
| C++ | [`libtmux::Session::new_window`](/en/cxx/latest/reference/libtmux-session-new_window/) (method) |
| Swift | [`Server.newWindow(in:named:startDirectory:at:environment:shell:)`](/en/swift/latest/reference/server-newwindow(in-named-startdirectory-)/) (method) |

No equivalent is recorded in PowerShell, Julia, Elixir or F#.
