We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f6123f2 commit e44368cCopy full SHA for e44368c
src/lib/is-browser.ts
@@ -1,6 +1,11 @@
1
const isBrowser =
2
(typeof window !== 'undefined' && typeof window.document !== 'undefined') ||
3
// eslint-disable-next-line no-restricted-globals
4
- (typeof self !== 'undefined' && typeof self.postMessage === 'function') || // is web worker
+ (typeof self === 'object' &&
5
+ // eslint-disable-next-line no-restricted-globals
6
+ self.constructor &&
7
8
+ self.constructor.name === 'DedicatedWorkerGlobalScope') || // is web worker
9
(typeof navigator !== 'undefined' && navigator.product === 'ReactNative') // while navigator.product is deprecated
10
+
11
export default isBrowser
0 commit comments