# dotenv-strict

> dotenv wrapper ensuring defined environment variables are present

Latest version **0.1.0** (published 2024-01-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install dotenv-strict
pnpm add dotenv-strict
yarn add dotenv-strict
bun add dotenv-strict
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2024-01-14 |
| First published | 2023-08-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 12 |
| Author | Aaron Casanova |
| Maintainers | aaronccasanova |

## Links

- npm: https://www.npmjs.com/package/dotenv-strict
- Repository: https://github.com/aaronccasanova/aacc
- Homepage: https://github.com/aaronccasanova/aacc/blob/main/packages/dotenv-strict/README.md
- Issues: https://github.com/aaronccasanova/aacc/issues
- npm.io page: https://npm.io/package/dotenv-strict

## Recent versions

- 0.1.0 (latest) — 2024-01-14
- 0.0.1 — 2023-09-13
- 0.0.0 — 2023-08-15

## README

# dotenv-strict

`dotenv-strict` ensures that your environment variables are not only loaded but
also validated. It ensures that specific variables are present, otherwise, it
will throw an error.

Extending the well-known [dotenv](https://www.npmjs.com/package/dotenv) package,
`dotenv-strict` adds a layer of strictness to your application's environment
configuration. It's useful for making sure that essential environment variables
are always set.

## Installation

Since `dotenv` is a peer dependency, you'll need to install both `dotenv` and
`dotenv-strict`:

```sh
npm i dotenv dotenv-strict
```

## Usage

Use `dotenv-strict` the same way you'd use `dotenv`, but with an additional
`strict`` property to enforce required variables:

```ts
import { config } from 'dotenv-strict'

const env = config({ strict: ['FOO', 'BAR'] as const })

const foo = env.parsed.FOO // string
const bar = env.parsed.BAR // string
const baz = env.parsed.BAZ // string | undefined
```

Missing any of the `strict` variables will throw an error, providing you with
confidence that your environment is correctly configured.

For more detailed usage and customization, refer to the
[`dotenv` documentation](https://github.com/motdotla/dotenv#options).

---
_Source: https://npm.io/package/dotenv-strict · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
