UNPKG

@naturalcycles/js-lib

Version:

Standard library for universal (browser + Node.js) javascript

24 lines (23 loc) 627 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isServerSide = isServerSide; exports.isClientSide = isClientSide; /** * Use it to detect SSR/Node.js environment. * * Will return `true` in Node.js. * Will return `false` in the Browser. */ function isServerSide() { return !isClientSide(); } /** * Use it to detect Browser (not SSR/Node) environment. * * Will return `true` in the Browser. * Will return `false` in Node.js. */ function isClientSide() { // eslint-disable-next-line unicorn/prefer-global-this return typeof window !== 'undefined' && !!window?.document; }