is-in-browser
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

Is In Browser?

import isBrowser from "is-in-browser";

if (isBrowser) {
  //...
}

More thoroughly:

import { isJsDom, isNode, isBrowser } from "is-in-browser";

if (isBrowser) {
  // you're in the browser
  // jsdom considered in browser
}

if (isJsDom) {
  // you're in the JSDom
}

if (isNode) {
  // you're in the Node
}

CommonJS

For those not using Babel / ES6 Modules

var isBrowser = require('is-in-browser').default;

if(isBrowser) { //... }

Dependencies (0)

    Dev Dependencies (15)

    Package Sidebar

    Install

    npm i is-in-browser

    Weekly Downloads

    2,029,234

    Version

    2.0.0

    License

    MIT

    Unpacked Size

    6.59 kB

    Total Files

    13

    Last publish

    Collaborators

    • tuxsudo