Search code examples
ios-simulatorreact-nativedeviceenvironment

How to know, if running on device or simulator in react native


To distinguish between development mode and production mode in react native there is the __DEV__ constant defined, when Debug = True.

Is there a similar constant defined, that lets me know within the code, if the code is running on the device or in the simulator?

Where else could I get this kind of information from.


Solution

  • You can use this package, then just do :

    console.log(DeviceInfo.getModel()); // it returns 'Simulator'