> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/expo/expo/llms.txt
> Use this file to discover all available pages before exploring further.

# expo-constants

> Access system information and app constants that remain unchanged throughout app lifetime

# expo-constants

**Version:** 55.0.5

Provides system information that remains constant throughout the lifetime of your app. Access app configuration, device info, manifest data, and environment constants.

## Installation

```bash theme={null}
npx expo install expo-constants
```

## Usage

```typescript theme={null}
import Constants from 'expo-constants';

// Get app information
console.log(Constants.expoConfig?.name);
console.log(Constants.expoConfig?.version);

// Get system information
console.log(Constants.systemVersion);
console.log(Constants.platform);

// Get device information
console.log(Constants.deviceName);
console.log(Constants.isDevice);
```

## API Reference

### Constants

<ResponseField name="expoConfig" type="ExpoConfig | null">
  The Expo configuration object from `app.json` or `app.config.js`

  ```typescript theme={null}
  const appName = Constants.expoConfig?.name;
  const version = Constants.expoConfig?.version;
  const slug = Constants.expoConfig?.slug;
  ```
</ResponseField>

<ResponseField name="expoGoConfig" type="ExpoGoConfig | null">
  Configuration specific to Expo Go app
</ResponseField>

<ResponseField name="manifest" type="Manifest | null">
  The classic manifest object (legacy)
</ResponseField>

<ResponseField name="manifest2" type="ExpoUpdatesManifest | null">
  The modern manifest format used by `expo-updates`
</ResponseField>

<ResponseField name="appOwnership" type="'expo' | 'standalone' | 'guest' | null">
  Indicates the type of app ownership:

  * `expo`: Running in Expo Go
  * `standalone`: Production build
  * `guest`: Guest mode
  * `null`: Bare workflow
</ResponseField>

### Device Information

<ResponseField name="deviceName" type="string | null">
  The human-readable device name (e.g., "John's iPhone")
</ResponseField>

<ResponseField name="isDevice" type="boolean">
  `true` if running on a physical device, `false` if simulator/emulator
</ResponseField>

<ResponseField name="platform" type="object">
  Platform-specific information:

  **iOS:**

  ```typescript theme={null}
  {
    ios: {
      platform: string;
      model: string;
      userInterfaceIdiom: 'phone' | 'tablet' | 'tv';
      systemVersion: string;
    }
  }
  ```

  **Android:**

  ```typescript theme={null}
  {
    android: {
      versionCode: number;
    }
  }
  ```
</ResponseField>

<ResponseField name="systemVersion" type="string">
  The OS version (e.g., "15.0" for iOS, "12" for Android API 31)
</ResponseField>

### App Information

<ResponseField name="nativeAppVersion" type="string | null">
  The native app version from `Info.plist` (iOS) or `build.gradle` (Android)

  Example: `"1.0.0"`
</ResponseField>

<ResponseField name="nativeBuildVersion" type="string | null">
  The native build number

  Example: `"42"` (iOS) or `"42"` (Android)
</ResponseField>

<ResponseField name="sessionId" type="string">
  A unique ID for this app session. Changes on each app launch.
</ResponseField>

<ResponseField name="statusBarHeight" type="number">
  Height of the device status bar in pixels
</ResponseField>

<ResponseField name="installationId" type="string">
  A unique ID for this app installation
</ResponseField>

### Development

<ResponseField name="debugMode" type="boolean">
  `true` if the app is running in debug mode
</ResponseField>

<ResponseField name="executionEnvironment" type="ExecutionEnvironment">
  The execution environment:

  * `ExecutionEnvironment.Bare`: Bare workflow
  * `ExecutionEnvironment.Standalone`: Production build
  * `ExecutionEnvironment.StoreClient`: Expo Go
</ResponseField>

### System Directories

<ResponseField name="systemFonts" type="string[]">
  **iOS only:** List of system font names available
</ResponseField>

## Examples

### Display App Version

```tsx theme={null}
import Constants from 'expo-constants';
import { Text, View } from 'react-native';

function AppVersion() {
  const version = Constants.expoConfig?.version;
  const buildNumber = Constants.nativeBuildVersion;
  
  return (
    <View>
      <Text>Version: {version}</Text>
      <Text>Build: {buildNumber}</Text>
    </View>
  );
}
```

### Check Environment

```typescript theme={null}
import Constants from 'expo-constants';

const isExpoGo = Constants.appOwnership === 'expo';
const isProduction = Constants.appOwnership === 'standalone';
const isBareWorkflow = Constants.appOwnership === null;

if (isExpoGo) {
  console.log('Running in Expo Go');
} else if (isProduction) {
  console.log('Running production build');
}
```

### Access Extra Config

**app.json:**

```json theme={null}
{
  "expo": {
    "name": "My App",
    "extra": {
      "apiUrl": "https://api.example.com",
      "apiKey": "abc123"
    }
  }
}
```

**Usage:**

```typescript theme={null}
import Constants from 'expo-constants';

const apiUrl = Constants.expoConfig?.extra?.apiUrl;
const apiKey = Constants.expoConfig?.extra?.apiKey;

fetch(`${apiUrl}/data`, {
  headers: {
    'Authorization': `Bearer ${apiKey}`
  }
});
```

### Environment-Specific Config

**app.config.js:**

```javascript theme={null}
export default {
  expo: {
    name: 'My App',
    extra: {
      apiUrl: process.env.API_URL || 'https://api.staging.example.com'
    }
  }
};
```

**Usage:**

```typescript theme={null}
import Constants from 'expo-constants';

const API_URL = Constants.expoConfig?.extra?.apiUrl;
```

### Device Detection

```typescript theme={null}
import Constants from 'expo-constants';
import { Platform } from 'react-native';

function getDeviceInfo() {
  return {
    isSimulator: !Constants.isDevice,
    deviceName: Constants.deviceName,
    osVersion: Constants.systemVersion,
    platform: Platform.OS,
    appVersion: Constants.expoConfig?.version
  };
}

const deviceInfo = getDeviceInfo();
console.log(deviceInfo);
// {
//   isSimulator: false,
//   deviceName: "John's iPhone",
//   osVersion: "17.0",
//   platform: "ios",
//   appVersion: "1.0.0"
// }
```

### Debug Information Display

```tsx theme={null}
import Constants from 'expo-constants';
import { ScrollView, Text, View, StyleSheet } from 'react-native';

function DebugInfo() {
  if (!__DEV__) return null;
  
  return (
    <ScrollView style={styles.container}>
      <Text style={styles.title}>Debug Information</Text>
      
      <Section title="App">
        <Info label="Name" value={Constants.expoConfig?.name} />
        <Info label="Version" value={Constants.expoConfig?.version} />
        <Info label="Build" value={Constants.nativeBuildVersion} />
        <Info label="Session ID" value={Constants.sessionId} />
      </Section>
      
      <Section title="Device">
        <Info label="Device" value={Constants.deviceName} />
        <Info label="Is Device" value={Constants.isDevice} />
        <Info label="OS Version" value={Constants.systemVersion} />
      </Section>
      
      <Section title="Environment">
        <Info label="App Ownership" value={Constants.appOwnership} />
        <Info label="Debug Mode" value={Constants.debugMode} />
      </Section>
    </ScrollView>
  );
}

function Section({ title, children }) {
  return (
    <View style={styles.section}>
      <Text style={styles.sectionTitle}>{title}</Text>
      {children}
    </View>
  );
}

function Info({ label, value }) {
  return (
    <Text style={styles.info}>
      {label}: {JSON.stringify(value)}
    </Text>
  );
}

const styles = StyleSheet.create({
  container: { padding: 20 },
  title: { fontSize: 24, fontWeight: 'bold', marginBottom: 20 },
  section: { marginBottom: 20 },
  sectionTitle: { fontSize: 18, fontWeight: '600', marginBottom: 10 },
  info: { fontSize: 14, marginBottom: 5 }
});
```

## TypeScript

```typescript theme={null}
import Constants, { ExecutionEnvironment } from 'expo-constants';
import type { ExpoConfig } from 'expo/config';

const config: ExpoConfig | null = Constants.expoConfig;
const env: ExecutionEnvironment = Constants.executionEnvironment;
```

## Platform Support

| Platform | Supported |
| -------- | --------- |
| iOS      | ✅         |
| Android  | ✅         |
| Web      | ✅         |

<Note>
  On web, some device-specific constants may not be available or return default values.
</Note>

## Resources

* [Official Documentation](https://docs.expo.dev/versions/latest/sdk/constants/)
* [GitHub Repository](https://github.com/expo/expo/tree/main/packages/expo-constants)
