---
title: "isClient"
description: "Check whether the code is running in a browser environment (has a `document`)."
package: "@maz-ui/utils"
url: "https://maz-ui.com/ecosystem/utils/is-client"
---

# isClient

> Check whether the code is running in a browser environment (has a `document`).

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

## Usage

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

if (isClient()) {
  document.body.classList.add('hydrated')
}
```

## API

```ts
function isClient(): boolean
```

Returns `true` if `document` is defined, `false` otherwise (e.g. SSR, Node.js, Web Workers).

## Notes

- The opposite is [`isServer`](./is-server.md).
- Implemented as a one-liner: `typeof document !== 'undefined'`.
- Prefer this over checking `process.client` (Nuxt) or `import.meta.env.SSR` (Vite) when you want a framework-agnostic check.
