# @arcjet/env

> Arcjet environment detection

Latest version **1.14.1** (published 2026-10-07) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @arcjet/env
pnpm add @arcjet/env
yarn add @arcjet/env
bun add @arcjet/env
```

## Health

**Score 75/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.14.1 |
| Published | 2026-10-07 |
| First published | 2024-06-10 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=22.21.0 <23 \|\| >=24.5.0 |
| Dependencies | 0 |
| Unpacked size | 21.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 685 |
| Author | Arcjet |
| Maintainers | quinn-arcjet, davidmytton |
| Keywords | arcjet, environment, util, utility |

## Links

- npm: https://www.npmjs.com/package/@arcjet/env
- Repository: https://github.com/arcjet/arcjet-js
- Homepage: https://arcjet.com
- Issues: https://github.com/arcjet/arcjet-js/issues
- npm.io page: https://npm.io/package/@arcjet/env

## Alternatives

- [replicas-cli](https://npm.io/package/replicas-cli.md) — 3.0K weekly downloads
- [env-contract](https://npm.io/package/env-contract.md) — 133 weekly downloads
- [@openveo/api](https://npm.io/package/@openveo/api.md) — 61 weekly downloads
- [@ryniaubenpm2/cumque-error-reiciendis](https://npm.io/package/@ryniaubenpm2/cumque-error-reiciendis.md) — 54 weekly downloads
- [ts-global-type-extra](https://npm.io/package/ts-global-type-extra.md) — 11 weekly downloads

## Recent versions

- 1.14.1 (latest) — 2026-10-07
- 1.10.0-rc.1 (rc) — 2026-08-07
- 1.14.0 — 2026-10-01
- 1.13.0 — 2026-09-16
- 1.12.0 — 2026-09-08
- 1.11.0 — 2026-08-26
- 1.10.0 — 2026-08-11
- 1.10.0-rc.0 — 2026-08-04
- 1.9.1 — 2026-07-15
- 1.9.0 — 2026-07-15
- 1.8.0 — 2026-07-07
- 1.8.0-rc.0 — 2026-07-07
- 1.7.0 — 2026-07-06
- 1.7.0-rc.1 — 2026-07-06
- 1.7.0-rc.0 — 2026-07-03
- … 49 more at https://npm.io/package/@arcjet/env/versions

## README

<!-- trunk-ignore-all(markdownlint/MD024) -->
<!-- trunk-ignore-all(markdownlint/MD001) -->

<a href="https://arcjet.com" target="_arcjet-home">
  <picture>
    <source media="(prefers-color-scheme: dark)" srcset="https://arcjet.com/logo/arcjet-dark-lockup-voyage-horizontal.svg">
    <img src="https://arcjet.com/logo/arcjet-light-lockup-voyage-horizontal.svg" alt="Arcjet Logo" height="128" width="auto">
  </picture>
</a>

# `@arcjet/env`

<p>
  <a href="https://www.npmjs.com/package/@arcjet/env">
    <picture>
      <source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/npm/v/%40arcjet%2Fenv?style=flat-square&label=%E2%9C%A6Aj&labelColor=000000&color=5C5866">
      <img alt="npm badge" src="https://img.shields.io/npm/v/%40arcjet%2Fenv?style=flat-square&label=%E2%9C%A6Aj&labelColor=ECE6F0&color=ECE6F0">
    </picture>
  </a>
</p>

[Arcjet][arcjet] environment detection.

- [npm package (`@arcjet/env`)](https://www.npmjs.com/package/@arcjet/env)
- [GitHub source code (`env/` in `arcjet/arcjet-js`)](https://github.com/arcjet/arcjet-js/tree/main/env)

## What is this?

This is a utility that reads configuration for us from `process.env` and
similar.
It exists so that we can access that configuration throughout our packages.

## When should I use this?

You should probably not use this but there are some edge cases where we let
users swap more advanced features out and then it may be useful.

## Install

This package is ESM only.
Install with npm in Node.js:

```sh
npm install @arcjet/env
```

## Use

```ts
import process from "node:process";
import { baseUrl, isDevelopment, logLevel, platform } from "@arcjet/env";

console.log(platform({ FLY_APP_NAME: "foobar" })); // => "fly-io"
console.log(platform({})); // => undefined
console.log(isDevelopment({ NODE_ENV: "production" })); // => false
console.log(isDevelopment({ NODE_ENV: "development" })); // => true
console.log(isDevelopment({ ARCJET_ENV: "production" })); // => false
console.log(isDevelopment({ ARCJET_ENV: "development" })); // => true
console.log(logLevel({ ARCJET_LOG_LEVEL: "debug" })); // => "debug"
console.log(logLevel({ ARCJET_LOG_LEVEL: "info" })); // => "info"
console.log(logLevel({ ARCJET_LOG_LEVEL: "warn" })); // => "warn"
console.log(logLevel({ ARCJET_LOG_LEVEL: "error" })); // => "error"
console.log(logLevel({ ARCJET_LOG_LEVEL: "" })); // => "warn"
console.log(baseUrl(process.env)); // => "https://decide.arcjet.com"
```

## API

This package exports the identifiers
[`baseUrl`][api-base-url],
[`isDevelopment`][api-is-development],
[`logLevel`][api-log-level], and
[`platform`][api-platform].
There is no default export.

This package exports the [TypeScript][] types
[`Env`][api-env] and
[`Platform`][api-platform-type].

### `Env`

This type represents the environment object that you pass to the functions in
this package. It includes known Arcjet and platform-specific environment
variables.

###### Type

```ts
export type Env = {
  [key: string]: unknown;
  ARCJET_BASE_URL?: string | undefined;
  ARCJET_ENV?: string | undefined;
  ARCJET_LOG_LEVEL?: string | undefined;
  FIREBASE_CONFIG?: string | undefined;
  FLY_APP_NAME?: string | undefined;
  MODE?: string | undefined;
  NODE_ENV?: string | undefined;
  RENDER?: string | undefined;
  VERCEL?: string | undefined;
};
```

### `Platform`

This type represents the platform names that can be detected.

###### Type

```ts
type Platform = "firebase" | "fly-io" | "render" | "vercel";
```

### `baseUrl(environment)`

Returns the base URL for the Arcjet API. You can use this if you need to
know which API endpoint Arcjet will talk to.

###### Parameters

- `environment` ([`Env`][api-env])
  — the environment object, typically `process.env`

###### Returns

Base URL of the Arcjet API (`string`).

### `isDevelopment(environment)`

Checks whether the current environment is a development environment. We use
this internally to adjust behavior between development and production.

###### Parameters

- `environment` ([`Env`][api-env])
  — the environment object, typically `process.env`

###### Returns

Whether the environment is development (`boolean`).

### `logLevel(environment)`

Returns the configured log level from the environment. If no log level is
set, it defaults to `"warn"`.

###### Parameters

- `environment` ([`Env`][api-env])
  — the environment object, typically `process.env`

###### Returns

Log level (`"debug" | "error" | "info" | "warn"`).

### `platform(environment)`

Detects which platform your code is running on based on environment
variables.

###### Parameters

- `environment` ([`Env`][api-env])
  — the environment object, typically `process.env`

###### Returns

Name of the platform if found ([`Platform`][api-platform]), or `undefined`
otherwise.

## License

[Apache License, Version 2.0][apache-license] © [Arcjet Labs, Inc.][arcjet]

[arcjet]: https://arcjet.com
[apache-license]: http://www.apache.org/licenses/LICENSE-2.0
[api-env]: #env
[api-base-url]: #baseurlenvironment
[api-is-development]: #isdevelopmentenvironment
[api-log-level]: #loglevelenvironment
[api-platform-type]: #platform
[api-platform]: #platformenvironment
[typescript]: https://www.typescriptlang.org/

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