[**Documentation**](../../../../README)

***

[Documentation](../../../../README) / [@zerotal/core](../../README) / [helpers](../README) / env

# Function: env()

## Call Signature

> **env**(`key`): `string` \| `undefined`

Defined in: [helpers/index.ts:100](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/core/src/helpers/index.ts#L100)

Read an environment variable with an optional typed fallback.

### Parameters

#### key

`string`

### Returns

`string` \| `undefined`

### Example

```ts
env('APP_NAME', 'Zerotal App')   // string
env('APP_DEBUG', false)        // boolean (coerces 'true'/'false' strings)
env('PORT', 3000)              // number  (coerces numeric strings)
env('APP_KEY')                 // string | undefined — no fallback
```

## Call Signature

> **env**(`key`, `fallback`): `string`

Defined in: [helpers/index.ts:101](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/core/src/helpers/index.ts#L101)

Read an environment variable with an optional typed fallback.

### Parameters

#### key

`string`

#### fallback

`string`

### Returns

`string`

### Example

```ts
env('APP_NAME', 'Zerotal App')   // string
env('APP_DEBUG', false)        // boolean (coerces 'true'/'false' strings)
env('PORT', 3000)              // number  (coerces numeric strings)
env('APP_KEY')                 // string | undefined — no fallback
```

## Call Signature

> **env**(`key`, `fallback`): `boolean`

Defined in: [helpers/index.ts:102](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/core/src/helpers/index.ts#L102)

Read an environment variable with an optional typed fallback.

### Parameters

#### key

`string`

#### fallback

`boolean`

### Returns

`boolean`

### Example

```ts
env('APP_NAME', 'Zerotal App')   // string
env('APP_DEBUG', false)        // boolean (coerces 'true'/'false' strings)
env('PORT', 3000)              // number  (coerces numeric strings)
env('APP_KEY')                 // string | undefined — no fallback
```

## Call Signature

> **env**(`key`, `fallback`): `number`

Defined in: [helpers/index.ts:103](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/core/src/helpers/index.ts#L103)

Read an environment variable with an optional typed fallback.

### Parameters

#### key

`string`

#### fallback

`number`

### Returns

`number`

### Example

```ts
env('APP_NAME', 'Zerotal App')   // string
env('APP_DEBUG', false)        // boolean (coerces 'true'/'false' strings)
env('PORT', 3000)              // number  (coerces numeric strings)
env('APP_KEY')                 // string | undefined — no fallback
```
