---
title: "isServer"
description: "Check whether the code is running on the server (no `window` or `document`)."
package: "@maz-ui/utils"
url: "https://maz-ui.com/ecosystem/utils/is-server"
---

# isServer

> Check whether the code is running on the server (no `window` or `document`).

- Package: `@maz-ui/utils`
- Import: `import { isServer } from '@maz-ui/utils/helpers/isServer'`
- Web: https://maz-ui.com/ecosystem/utils/is-server

## Usage

```ts
import { isServer } from '@maz-ui/utils'

if (isServer()) {
  return placeholder
}
```

## API

```ts
function isServer(): boolean
```

Returns `true` when either `document` or `window` is undefined - covers Node.js, Bun, Deno, Edge runtimes and Web Workers.

## Notes

- The opposite is [`isClient`](./is-client.md).
- Useful for guarding `window`-dependent code from SSR errors.
