universal-env
Judge runtime environment
Support
Install
$ npm install universal-env --save
Usage
import { isWeex, isWeb, isMiniApp, isNode, isWeChatMiniprogram } from 'universal-env';
APIS
isWeex: boolean
Checks if environment is a weex environment.
isWeb: boolean
Checks if environment is a web environment.
isMiniApp: boolean
Checks if environment is an alibaba miniprogram environment.
isWeChatMiniprogram: boolean
Checks if environment is a wechat miniprogram environment.
isNode: boolean
Checks if environment is a Node.js environment.
Results in each container
| isMiniApp | isWeChatMiniprogram | isWeb | isWeex | isNode |
---|
Alibaba MiniApp | ✔️ | ✘ | ✘ | ✘ | ✘ |
Alibaba MiniApp WebView | ✔️ | ✘ | ✔️ | ✘ | ✘ |
Wechat Miniprogram | ✘ | ✔️ | ✘ | ✘ | ✘ |
Wechat Miniprogram WebView | ✘ | ✔️ | ✔️ | ✘ | ✘ |
Weex | ✘ | ✘ | ✘ | ✔️ | ✘ |
Node | ✘ | ✘ | ✘ | ✘ | ✔️ |
Web | ✘ | ✘ | ✔️ | ✘ | ✘ |