Code Reference

Constants

Expo · Reference cheat sheet

Constants

Expo · Reference cheat sheet


📋 Overview

expo-constants exposes app metadata from the native manifest / config: version, expoConfig, installation id (where available), and EAS project fields. Use for feature flags wiring, update URLs, and debugging—not for secrets.

🔧 Core concepts

FieldRole
Constants.expoConfigApp config (name, slug, extra, …)
Constants.easConfigEAS ids when present
nativeAppVersion / nativeBuildVersionStore versions
executionEnvironmentstoreClient / standalone / …
appOwnershipexpo / standalone (legacy nuances)

extra comes from app.configexpo.extra.

💡 Examples

import Constants from "expo-constants";
import { Text } from "react-native";

export function BuildStamp() {
  const version = Constants.expoConfig?.version ?? "dev";
  const projectId =
    Constants.expoConfig?.extra?.eas?.projectId ??
    Constants.easConfig?.projectId;
  return (
    <Text>
      v{version} · {projectId ?? "no-project"}
    </Text>
  );
}

export function apiBaseUrl() {
  return (
    Constants.expoConfig?.extra?.apiUrl ??
    process.env.EXPO_PUBLIC_API_URL ??
    ""
  );
}
// app.config.ts
extra: {
  apiUrl: process.env.EXPO_PUBLIC_API_URL,
  eas: { projectId: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" },
}

⚠️ Pitfalls

  • Putting secrets in extra (shipped in the binary).
  • Assuming manifest legacy fields on new SDKs—prefer expoConfig.
  • Using Constants for values that change per environment without rebuild/update.
  • Null access before config is available—optional chain.

On this page