or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

index.mdmanifests-config.md
tile.json

index.mddocs/

Expo Constants

Expo Constants provides system information that remains constant throughout the lifetime of your app. It offers comprehensive access to device information, app manifests, execution environment details, and platform-specific data across iOS, Android, and web platforms.

Package Information

  • Package Name: expo-constants
  • Package Type: npm
  • Language: TypeScript
  • Installation: npx expo install expo-constants

Core Imports

import Constants from "expo-constants";

For accessing specific types:

import Constants, { 
  ExecutionEnvironment, 
  UserInterfaceIdiom,
  AppOwnership,
  type AndroidManifest,
  type IOSManifest,
  type PlatformManifest,
  type WebManifest,
  type ManifestAsset,
  type Manifest,
  type ManifestExtra,
  type EASConfig,
  type ClientScopingConfig,
  type ExpoGoConfig,
  type ExpoGoPackagerOpts
} from "expo-constants";

CommonJS:

const Constants = require("expo-constants").default;

Basic Usage

import Constants from "expo-constants";

// Access system information
console.log("App name:", Constants.expoConfig?.name);
console.log("Version:", Constants.expoConfig?.version);
console.log("Device name:", Constants.deviceName);
console.log("Execution environment:", Constants.executionEnvironment);

// Check platform
if (Constants.platform?.ios) {
  console.log("iOS version:", Constants.platform.ios.systemVersion);
} else if (Constants.platform?.android) {
  console.log("Android version code:", Constants.platform.android.versionCode);
}

// Access session information
console.log("Session ID:", Constants.sessionId);
console.log("Linking URI:", Constants.linkingUri);

Architecture

Expo Constants is built around several key components:

  • Native Bridge: Uses ExponentConstants native module for platform-specific data access
  • Multi-Platform Support: Separate implementations for native (iOS/Android), web, and server environments
  • Manifest System: Handles multiple manifest types (legacy, modern, embedded) with automatic fallback
  • Type Safety: Comprehensive TypeScript definitions for all platforms and configurations
  • Runtime Detection: Dynamically determines execution environment and available features

Capabilities

System Information Access

Core system and device information that remains constant during app execution.

interface NativeConstants {
  /** Module name (hidden) */
  name: 'ExponentConstants';
  /** App ownership status (deprecated, use executionEnvironment) */
  appOwnership: AppOwnership | null;
  /** Returns `true` when the app is running in debug mode */
  debugMode: boolean;
  /** A human-readable name for the device type */
  deviceName?: string;
  /** The device year class (deprecated, use expo-device) */
  deviceYearClass: number | null;
  /** Current execution environment */
  executionEnvironment: ExecutionEnvironment;
  /** Experience URL */
  experienceUrl: string;
  /** Expo runtime version */
  expoRuntimeVersion: string | null;
  /** Expo Go app version (null in bare workflow and web) */
  expoVersion: string | null;
  /** Detached status */
  isDetached?: boolean;
  /** Intent URI */
  intentUri?: string;
  /** Returns `true` if the app is running in headless mode */
  isHeadless: boolean;
  /** App linking URI */
  linkingUri: string;
  /** Unique session ID */
  sessionId: string;
  /** Default status bar height for the device */
  statusBarHeight: number;
  /** List of system font names available on the current device */
  systemFonts: string[];
  /** System version */
  systemVersion?: number;
  /** Supported Expo SDKs (hidden) */
  supportedExpoSdks?: string[];
  /** Get web view user agent string */
  getWebViewUserAgentAsync(): Promise<string | null>;
}

Manifest and Configuration Access

Access to app manifests and configuration data across different deployment scenarios.

interface Constants extends NativeConstants {
  /** Legacy embedded manifest (deprecated, use expoConfig) - Dynamic getter */
  manifest: EmbeddedManifest | null;
  /** Modern Expo Updates manifest - Dynamic getter */
  manifest2: ExpoUpdatesManifest | null;
  /** Standard Expo config object from app.json/app.config.js - Dynamic getter */
  expoConfig: (ExpoConfig & { hostUri?: string }) | null;
  /** Expo Go specific configuration - Dynamic getter */
  expoGoConfig: ExpoGoConfig | null;
  /** EAS specific configuration - Dynamic getter */
  easConfig: EASConfig | null;
  /** Platform-specific manifest data */
  platform?: PlatformManifest;
  /** Internal manifest access without warning (for expo-asset) - Dynamic getter */
  __unsafeNoWarnManifest?: EmbeddedManifest;
  /** Internal manifest2 access without warning - Dynamic getter */
  __unsafeNoWarnManifest2?: ExpoUpdatesManifest;
  /** Test-only raw manifest access - Dynamic getter/setter */
  __rawManifest_TEST?: RawManifest | null;
}

Manifests and Configuration

Types

Execution Environment

enum ExecutionEnvironment {
  /** Bare React Native app */
  Bare = 'bare',
  /** Standalone app */
  Standalone = 'standalone', 
  /** Store client */
  StoreClient = 'storeClient',
}

User Interface Idiom

enum UserInterfaceIdiom {
  /** Phone interface */
  Handset = 'handset',
  /** Tablet interface */
  Tablet = 'tablet',
  /** Desktop interface */
  Desktop = 'desktop',
  /** TV interface */
  TV = 'tv',
  /** Unsupported interface (e.g., CarPlay) */
  Unsupported = 'unsupported',
}

App Ownership (Deprecated)

enum AppOwnership {
  /** Running inside Expo Go (deprecated, use ExecutionEnvironment) */
  Expo = 'expo',
}

Platform Manifest

interface PlatformManifest {
  /** iOS-specific manifest */
  ios?: IOSManifest;
  /** Android-specific manifest */
  android?: AndroidManifest;
  /** Web-specific manifest */
  web?: WebManifest;
  /** Detach configuration */
  detach?: {
    scheme?: string;
    [key: string]: any;
  };
  /** URL scheme */
  scheme?: string;
  /** Host URI */
  hostUri?: string;
  /** Developer information */
  developer?: string;
}

iOS Manifest

interface IOSManifest {
  /** Build number from Info.plist CFBundleVersion */
  buildNumber: string | null;
  /** Apple internal model identifier (deprecated, use expo-device) */
  platform: string;
  /** Human-readable device model (deprecated, use expo-device) */
  model: string | null;
  /** User interface idiom (deprecated, use expo-device) */
  userInterfaceIdiom: UserInterfaceIdiom;
  /** iOS version (deprecated, use expo-device) */
  systemVersion: string;
}

Android Manifest

interface AndroidManifest {
  /** Version code from android.versionCode (deprecated, use expo-application) */
  versionCode: number;
}

Web Manifest

type WebManifest = Record<string, any>;

Complete Type Definitions

/** Embedded manifest interface */
interface EmbeddedManifest extends ExpoConfig {
  id: string;
  commitTime: number;
  assets: any[];
  // Legacy format for backwards compatibility
}

/** Expo Updates manifest interface */
interface ExpoUpdatesManifest {
  id: string;
  createdAt: string;
  runtimeVersion: string;
  launchAsset: ManifestAsset;
  assets: ManifestAsset[];
  metadata: object;
  extra?: {
    expoClient?: ExpoConfig;
    expoGo?: ExpoGoConfig;
    eas?: EASConfig;
  };
}

/** Raw manifest union type for internal use */
type RawManifest = ExpoUpdatesManifest | EmbeddedManifest | ExpoConfig;

Re-exported Types

/** Manifest asset type (from expo-manifests) */
type ManifestAsset = ManifestAssetForReExport;

/** Modern manifest type alias (same as ExpoUpdatesManifest) */
type Manifest = ExpoUpdatesManifest;

/** Manifest extra data type (from expo-manifests) */
type ManifestExtra = ManifestExtraForReExport;

/** EAS configuration type (from expo-manifests) */
type EASConfig = ManifestsEASConfig;

/** Client scoping configuration type (from expo-manifests) */
type ClientScopingConfig = ClientScopingConfigForReExport;

/** Expo Go configuration type (from expo-manifests) */
type ExpoGoConfig = ManifestsExpoGoConfig;

/** Expo Go packager options type (from expo-manifests) */
type ExpoGoPackagerOpts = ExpoGoPackagerOptsForReExport;

Error Handling

/** Error thrown when manifest is unavailable in standalone/store environments */
interface ConstantsError extends Error {
  code: 'ERR_CONSTANTS_MANIFEST_UNAVAILABLE';
  message: string;
}

Usage Examples:

import Constants, { ExecutionEnvironment } from "expo-constants";

try {
  // Accessing manifest in different environments
  const manifest = Constants.manifest;
  
  if (Constants.executionEnvironment === ExecutionEnvironment.Bare) {
    // In bare workflow, manifest can be null without error
    // Warning may be logged to console
    if (!manifest) {
      console.log("Manifest not available in bare workflow");
    }
  } else if (
    Constants.executionEnvironment === ExecutionEnvironment.Standalone ||
    Constants.executionEnvironment === ExecutionEnvironment.StoreClient
  ) {
    // In standalone/store environments, manifest should always exist
    // Will throw CodedError if null
    console.log("Manifest guaranteed to exist:", manifest);
  }
} catch (error) {
  if (error.code === 'ERR_CONSTANTS_MANIFEST_UNAVAILABLE') {
    console.error("Manifest is unexpectedly unavailable:", error.message);
  }
}

Platform-Specific Behavior

Web Platform:

  • deviceName returns browser name
  • systemFonts returns empty array []
  • statusBarHeight is always 0
  • deviceYearClass is always null
  • Manifest data comes from process.env.APP_MANIFEST

Server-Side Rendering:

  • Use server-compatible import: "expo-constants/server"
  • Safe for React Server Components

Dynamic Properties: The following properties are dynamic getters, not static values:

  • manifest, manifest2, expoConfig, expoGoConfig, easConfig
  • __unsafeNoWarnManifest, __unsafeNoWarnManifest2
  • __rawManifest_TEST (getter/setter for test environments)