# server.Server.hasSession

- **Module:** server.Server
- **Package:** @libtmux/libtmux
- **Language:** TypeScript
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-ts/blob/2cb93308200da38a26b59876618116850f110607/packages/libtmux/src/server.ts#L790
- **Page:** https://libtmux.org/reference/ts/server-server-hassession/

```
server.Server.hasSession(name: : string) -> Promise<boolean>
```

Whether a session with this name exists.

The name is matched exactly. tmux normally accepts a unique prefix as a
session target, which would make checking `work` answer yes for
`workspace`; this method does not.

## Example

```ts
if (!(await server.hasSession("work"))) {
  await server.newSession({ name: "work" });
}
```
