---
title: 'Environment constants'
slug: environment-constants
description: 'Build-time constants for branching on render target (isServer, isBrowser) and development mode (isDev).'
---
## Environment constants
Import build-time constants from the `mochi-framework` virtual module to branch on render target or dev mode:
```ts
import { isServer, isBrowser, isDev } from 'mochi-framework';
```
`mochi-framework` resolves to one of two virtual modules at compile time — server builds export `isServer = true`, client bundles export `isBrowser = true`. The values are literal booleans, so `if (isBrowser) { … }` blocks dead-code-eliminate out of the opposite bundle.
Do **NOT** read `process.env.NODE_ENV` or `typeof window` to detect environment; instead, import these constants — they survive bundling intact.
### `isServer`
`true` during server-side rendering, `false` in the browser.
```svelte
```
### `isBrowser`
`true` in the client bundle, `false` on the server. Use it to gate browser-only APIs (`window`, `document`, `IntersectionObserver`).
```svelte
```
### `isDev`
`true` when `Mochi.serve()` was started with `development: true`. Identical on server and client builds.
```ts
// file: src/lib/log.ts
import { isDev } from 'mochi-framework';
export function trace(msg: string) {
if (isDev) console.log('[trace]', msg);
}
```
## Auto-injected island props
The preprocessor injects one extra prop on every component invoked with `mochi:hydrate`, `mochi:hydrate:visible`, or `mochi:defer mochi:hydrate`:
- `isHydratable` (`true | undefined`): `true` for hydratable invocations, absent on plain SSR-only invocations.
Accept it with `$props`:
```svelte
```
For a unique per-instance id (e.g. `