Reputation: 4064
I would like to determine in react native code if the app is running in Expo Go or as a stand-alone iOS/Android app.
I can’t use __DEV__
, because I would like to be able to determine this also for a production build.
Upvotes: 14
Views: 7198
Reputation: 450
in case you are using EAS Builds with TypeScript and since ExecutionEnvironment
is an enum that looks like that:
export enum ExecutionEnvironment {
Bare = 'bare', Standalone = 'standalone', StoreClient = 'storeClient'}
the correct way to determine current environment will be:
Constants.executionEnvironment === ExecutionEnvironment.Standalone
or for Bare React Native Apps:
Constants.executionEnvironment === ExecutionEnvironment.Bare
Upvotes: 5
Reputation: 3576
Since classic builds are now deprecated and everyone will start using EAS Builds
, you will need to use Constants.ExecutionEnvironment
instead of appOwnership
which is always null
in builds done via EAS
.
So you could use the following to check if in production:
ExecutionEnvironment.Standalone === "standalone"
Documentation can be found here
Upvotes: 5
Reputation: 772
You can use Expo's AppOwnership
from Constants
import Constants from 'expo-constants'
const isRunningInExpoGo = Constants.appOwnership === 'expo'
Upvotes: 28