# tmux.Window.NewWindow

- **Module:** tmux.Window
- **Package:** github.com/libtmux/libtmux-go/tmux
- **Language:** Go
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-go/blob/5f808882015a975a65acc7f9da5b3ff0d5cbdc91/tmux/window_lifecycle.go#L104
- **Page:** https://libtmux.org/reference/go/tmux-window-newwindow/

```
tmux.Window.NewWindow(ctx: context.Context, request: NewWindowRequest) -> (Window, error)
```

NewWindow creates a window relative to the receiver's exact winlink. Set Direction to [NewWindowDirectionAfter] or [NewWindowDirectionBefore] for non-destructive relative creation. With the zero Direction, tmux targets the receiver's occupied index and normally returns a command error; KillExisting can destroy and replace that target. Attach changes the current window only in that target session. Index is rejected before execution because the receiver already supplies the target position. SelectExisting has no no-output recovery on this exact-target form; tmux must print the created WindowID.

If tmux reports an ID before a transport or refresh failure, the partial result
contains it and the receiver SessionID with Index -1. Other failures return
zero; creation is not rolled back.
