by JedWatson

JedWatson / exenv

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

214 Stars 18 Forks Last release: Not found Other 17 Commits 3 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:


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


npm install exenv --save
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


lib in React 0.13 includes an
property, which is
. 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.


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!

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.