Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

environ

kjs3171MIT3.0.3TypeScript support: included

Pretty secure detection of Node, browser, Electron, Deno, and other execution environments.

js env, js environment, browser, browser check, node, node check, is node, is browser, is electron, is deno, is jsdom

readme

Environ

Pretty secure detection of Node, browser, Electron, Deno, and other execution environments.

  • Zero dependencies.
  • Tree-shaking friendly so you're only left with what you use.

Install

yarn add environ

Or

npm install --save environ

Usage

// esm usage (Typescript, Babel,  Node 12+ with flags)
import { isBrowser } from 'environ'

// commonjs usage
const { isBrowser } = require('environ')

if (isBrowser()) {
  // do something
}