# exenv

> React's ExecutionEnvironment module extracted for use in other packages & components

Latest version **1.2.2** (published 2017-04-23) · BSD-3-Clause license · 0 weekly downloads

## Install

```sh
npm install exenv
pnpm add exenv
yarn add exenv
bun add exenv
```

## Health

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

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.2 |
| Published | 2017-04-23 |
| First published | 2015-04-14 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | separate (@types/exenv) |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 233 |
| Author | Jed Watson |
| Maintainers | jedwatson |
| Keywords | react, browser, server, environment, env, execution, executionenvironment |

## Links

- npm: https://www.npmjs.com/package/exenv
- Repository: https://github.com/JedWatson/exenv
- Issues: https://github.com/JedWatson/exenv/issues
- npm.io page: https://npm.io/package/exenv

## 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.2.2 (latest) — 2017-04-23
- 1.2.1 — 2016-04-11
- 1.2.0 — 2015-06-01
- 1.1.0 — 2015-04-15
- 1.0.0 — 2015-04-14

## README

# exenv

React's ExecutionEnvironment module extracted for use in other packages &amp; components.

## Usage

```
npm install exenv --save
```

```js
var ExecutionEnvironment = require('exenv');

// You now have...
ExecutionEnvironment.canUseDOM             // is the DOM available? i.e window document etc. 
ExecutionEnvironment.canUseWorkers         // are Web Workers available?
ExecutionEnvironment.canUseEventListeners  // are Events available? i.e addEventListener etc.
ExecutionEnvironment.canUseViewport        // is there a viewport? i.e window.screen
```

### Differences from React's ExecutionEnvironment

The `ExecutionEnvironment` lib in React 0.13 includes an `isInWorker` property, which is `!canUseDOM`. This is highly specific to React internals and probably (a) hacky and (b) not useful to other packages, so it has been left out. Please open an issue with your thoughts if you disagree or have a better idea.

## Why?

A number of packages and components use React's private ExecutionEnvironment lib to detect available features, particularly to detect server-side rendering, e.g

```
canUseDOM = require('react/lib/ExecutionEnvironment').canUseDOM; // BAD
```

**It is bad practice to use React internals** and this is likely to be broken / disabled in the future.

Use this package instead!

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