Platform detection: NodeJS? React? ReactNative? Expo? etc.
npm install who-am-i-now

Which platform am I on?
Do you need to run platform specific code?
If you need to (programmatically) find the answer to one of the following questions then this package is for you:
- _"is my app a react frontend?"_
- _"is my app a nextjs app?"_
- _"is my app a PWA standalone (installed) app?"_
- _"is my app a react-native app?"_
- _"is my app an expo app?"_
- _"is my react-native or expo app running on ios, android or web?"_
- _"is my app a plain node server?"_
- etc.
This package is extending the functionality of react-device-detect, by additionally detecting which 'platform' your code is running on and other things.
https://snack.expo.dev/@maks-io/who-am-i-now-demo
https://stackblitz.com/edit/who-am-i-now-react
https://stackblitz.com/edit/who-am-i-now-nextjs
Via npm:
``bash`
npm i who-am-i-now --save
Via yarn:
`bash`
yarn add who-am-i-now
`typescript
import WhoAmINow, { Who } from "who-am-i-now";
const who: Who = WhoAmINow();
// Example result:
// who = {
// isMobile: true,
// isBrowser: false,
// isReactNativeApp: true,
// isReactNativeAppIOS: true,
// isReactNativeAppAndroid: false,
// isReactNativeAppWeb: false,
// isExpoApp: true,
// isReactApp: false,
// isNextApp: false,
// isTWA: false,
// isPWAStandalone: false,
// isServerApp: false,
// ... and many others - check section below for details
// }
`
The result of calling whoAmINow() is an object holding various selectors/booleans/values.
Every prop is either
- inheriting the behaviour from the original react-device-detect library (entries marked with \\), orreact-device-detect
- having a different behaviour compared to the original library (entries marked with \*), or
- completely new (entries in table without asterisks)
| selector | type | explanation |
| ----------------------- | -------------------- |-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| isReactNativeApp | boolean | returns true if code is running in a react-native app (with and without expo) |true
| isReactNativeAppIOS | boolean | returns if code is running in a react-native app (with and without expo) and if the platform is ios |true
| isReactNativeAppAndroid | boolean | returns if code is running in a react-native app (with and without expo) and if the platform is android |true
| isReactNativeAppWeb | boolean | returns if code is running in a react-native app (with and without expo) and if the platform is web (Note that this will be false if code is running in a plain react web app!) |true
| isExpoApp | boolean | returns if code is running in a react-native app via expo |true
| isExpoAppRunningInGo | boolean \| undefined | returns if code is running in expo Go, returns false otherwise, if it is still an expo app, and returns undefined in every other case |true
| isExpoSnack | boolean \| undefined | returns if code is running in an expo snack, returns false otherwise, if it is still an expo app, and returns undefined in every other case |true
| isReactApp | boolean | returns if code is running in a react app |true
| isNextApp | boolean | returns if code is running in a nextjs app |true
| isTWA | boolean | returns if code is running as part of an android trusted web activities app |true
| isPWAStandalone | boolean | returns if code is running as part of a progressive web app / PWA in standalone mode, meaning in an installed way (for instance, after user decided to _"add app to homescreen"_ etc.) |true
| isServerApp | boolean | returns if code is running in a plain node "server" app (imagine a classical express api/server for instance) |true
| isCI | boolean | returns if code is running as part of a continuous integration / CI pipeline (since version 2.1.0 it relies on the is-ci package) |true
| isTestRun | boolean | returns if code is running as part of a test run (for instance jest unit tests, etc. - it relies on the environment to set the variable NODE_ENV=test) |true
| isJestTestRun | boolean | returns if code is running as part of a jest test run |true
| isCypressTestRun | boolean | returns if code is running as part of a cypress test run |true
| isBrowser\* | boolean | returns if code is running in a browser - the behaviour from react-device-detect was slightly changed |true
| isMobile\* | boolean | returns if code is running in a react-native app (with and without expo) but not in web browser (via react-native-web) |true
| isDesktop\* | boolean | returns if code is NOT running in a react-native app (with and without expo) - in other words, this is the opposite of isMobile above |react-device-detect
| isMobileOnly\\ | boolean | returns the same value returns |react-device-detect
| isTablet\\ | boolean | returns the same value returns |react-device-detect
| isSmartTV\\ | boolean | returns the same value returns |react-device-detect
| isWearable\\ | boolean | returns the same value returns |react-device-detect
| isConsole\\ | boolean | returns the same value returns |react-device-detect
| isEmbedded\\ | boolean | returns the same value returns |react-device-detect
| isAndroid\\ | boolean | returns the same value returns |react-device-detect
| isWinPhone\\ | boolean | returns the same value returns |react-device-detect
| isIOS\\ | boolean | returns the same value returns |react-device-detect
| isChrome\\ | boolean | returns the same value returns |react-device-detect
| isFirefox\\ | boolean | returns the same value returns |react-device-detect
| isSafari\\ | boolean | returns the same value returns |react-device-detect
| isOpera\\ | boolean | returns the same value returns |react-device-detect
| isIE\\ | boolean | returns the same value returns |react-device-detect
| isEdge\\ | boolean | returns the same value returns |react-device-detect
| isYandex\\ | boolean | returns the same value returns |react-device-detect
| isChromium\\ | boolean | returns the same value returns |react-device-detect
| isMobileSafari\\ | boolean | returns the same value returns |react-device-detect
| isSamsungBrowser\\ | boolean | returns the same value returns |react-device-detect
| osVersion\\ | string | returns the same value returns |react-device-detect
| osName\\ | string | returns the same value returns |react-device-detect
| fullBrowserVersion\\ | string | returns the same value returns |react-device-detect
| browserVersion\\ | string | returns the same value returns |react-device-detect
| browserName\\ | string | returns the same value returns |react-device-detect
| mobileVendor\\ | string | returns the same value returns |react-device-detect
| mobileModel\\ | string | returns the same value returns |react-device-detect
| engineName\\ | string | returns the same value returns |react-device-detect
| engineVersion\\ | string | returns the same value returns |react-device-detect
| getUA\\ | string | returns the same value returns |react-device-detect
| deviceType\\ | string | returns the same value returns |react-device-detect
| isIOS13\\ | boolean | returns the same value returns |react-device-detect
| isIPhone13\\ | boolean | returns the same value returns |react-device-detect
| isIPad13\\ | boolean | returns the same value returns |react-device-detect
| isIPod13\\ | boolean | returns the same value returns |react-device-detect
| isElectron\\ | boolean | returns the same value returns |react-device-detect
| isEdgeChromium\\ | boolean | returns the same value returns |react-device-detect
| isLegacyEdge\\ | boolean | returns the same value returns |react-device-detect
| isWindows\\ | boolean | returns the same value returns |react-device-detect` returns |
| isMacOs\\ | boolean | returns the same value
Youtube short: https://youtube.com/shorts/sKyRYo9h514?feature=share