# @dcl/ui-env

> This package can be used to generate configurations for different environments for web apps and frontends in general. This is handy for frontends that have a single build that is deployed to different envs (such as rollouts).

Latest version **2.1.0** (published 2026-09-14) · ISC license · 0 weekly downloads

## Install

```sh
npm install @dcl/ui-env
pnpm add @dcl/ui-env
yarn add @dcl/ui-env
bun add @dcl/ui-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 | 2.1.0 |
| Published | 2026-09-14 |
| First published | 2022-06-02 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 17 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 0 |
| Maintainers | decentralandbot, imazzara |

## Links

- npm: https://www.npmjs.com/package/@dcl/ui-env
- Repository: https://github.com/decentraland/ui-env
- Homepage: https://github.com/decentraland/ui-env#readme
- Issues: https://github.com/decentraland/ui-env/issues
- npm.io page: https://npm.io/package/@dcl/ui-env

## Recent versions

- 2.1.0 (latest) — 2026-09-14
- 2.0.1-20260914125642.commit-886d7e8 (next) — 2026-09-14
- 2.0.1-20260605150314.commit-55bf0fe — 2026-06-05
- 2.0.0 — 2026-01-06
- 1.5.2-20260106171541.commit-2d28bb6 — 2026-01-06
- 1.5.1 — 2024-08-05
- 1.5.1-20240805145018.commit-c869aa9 — 2024-08-05
- 1.5.0 — 2024-01-25
- 1.4.2-20240125143127.commit-48c62ff — 2024-01-25
- 1.4.1 — 2023-12-20
- 1.4.1-20231220185516.commit-b0413f4 — 2023-12-20
- 1.4.0 — 2023-07-03
- 1.3.1-20230703202140.commit-59ae18e — 2023-07-03
- 1.3.0 — 2022-10-13
- 1.2.2-20221013152949.commit-c0608ac — 2022-10-13
- … 14 more at https://npm.io/package/@dcl/ui-env/versions

## README

# ui-env

This package can be used to generate configurations for different environments for web apps and frontends in general. This is handy for frontends that have a single build that is deployed to different envs (such as rollouts).

## Installation

```bash
npm i @dcl/ui-env
```

## Usage

You need to create a `config` instance passing the different variables for all the desired envs.

```js
// config/env/dev|stg|prod.json
{
  "FOO": "bar"
}
```

```ts
// config/index.ts
import { Env, createConfig } from '@dcl/ui-env'
import dev from './env/dev.json'
import stg from './env/stg.json'
import prod from './env/prod.json'

export const config = createConfig({
  [Env.DEVELOPMENT]: dev,
  [Env.STAGING]: stg,
  [Env.PRODUCTION]: prod,
})
```

And then you can get the values for variables from other parts of your code base

```ts
// some-file.ts
import { config } from './config'

const someVar = config.get('FOO') // "bar"
```

You can pass default values as the second argument

```ts
const someVar = config.get('NON_EXISTENT_VAR', 'defaultValue') // "defaultValue"
```

The config will pick the value from the right environment by checking the top level domain:

- `Env.DEVELOPMENT`: If TLD is `.io` or `.zone`
- `Env.STAGING`: If TLD is `.net` or `.today`
- `Env.PRODUCTION`: If TLD is `.org`

You can override this logic by passing a query param `env` with the values `dev`, `stg` or `prod`. The param name and its value can be either uppercase or lowercase.

For example:

- `https://builder.decentraland.io?env=prod`: This will use `Env.PRODUCTION`
- `http://localhost:3000?env=dev`: This will use `Env.DEVELOPMENT`

If no TLD is found and there is no query param, the default environment will be used, which is `Env.PRODUCTION`.

If you want to override the default environment you can use the environment var `DCL_DEFAULT_ENV`, `REACT_APP_DCL_DEFAULT_ENV` or `VITE_DCL_DEFAULT_ENV` and set it with the values `dev`, `stg` or `prod`.

This can be useful to configure the local environment or for deployments to other non-decentraland domains such as Vercel's.

For example:

```bash
# .env
REACT_APP_DCL_DEFAULT_ENV=dev
```

Now `http://localhost:3000` uses the `Env.DEVELOPMENT` configuration without having to pass a query param.

## Test

```bash
npm test
```

Or with coverage reports

```bash
npm run test:coverage
```

## Build

```bash
npm run build
```

## Release

To release a new version of this package create a [new release](https://github.com/decentraland/ui-env/releases) via GitHub

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