🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@arcjet/env

Package Overview
Dependencies
Maintainers
2
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@arcjet/env

Arcjet environment detection

Source
npmnpm
Version
1.6.0
Version published
Weekly downloads
63K
-34.81%
Maintainers
2
Weekly downloads
 
Created
Source
Arcjet Logo

@arcjet/env

npm badge

Arcjet environment detection.

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:

npm install @arcjet/env

Use

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, isDevelopment, logLevel, and platform. There is no default export.

This package exports the TypeScript types Env and Platform.

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
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
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) — 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) — 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) — 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) — the environment object, typically process.env
Returns

Name of the platform if found (Platform), or undefined otherwise.

License

Apache License, Version 2.0 © Arcjet Labs, Inc.

Keywords

arcjet

FAQs

Package last updated on 30 Jun 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts