@expo/config provides comprehensive configuration management for Expo applications. It enables developers to parse, validate, and manipulate app.json and expo configuration files with support for both static and dynamic configurations, plugin systems, and workspace-aware path resolution.
npm install @expo/configimport { getConfig, getPackageJson, getExpoSDKVersion } from "@expo/config";For CommonJS:
const { getConfig, getPackageJson, getExpoSDKVersion } = require("@expo/config");Path utilities (separate entry point):
import { resolveEntryPoint, getBareExtensions } from "@expo/config/paths";import { getConfig, getExpoSDKVersion } from "@expo/config";
// Read Expo project configuration
const projectRoot = "/path/to/expo-project";
const config = getConfig(projectRoot);
console.log("App name:", config.exp.name);
console.log("App slug:", config.exp.slug);
console.log("SDK version:", config.exp.sdkVersion);
// Get just the package.json
const packageJson = getPackageJson(projectRoot);
// Get SDK version explicitly
const sdkVersion = getExpoSDKVersion(projectRoot, config.exp);@expo/config is built around several key components:
Core functionality for reading, parsing, and modifying Expo project configurations. Supports both static (JSON) and dynamic (JavaScript/TypeScript) configuration files.
function getConfig(projectRoot: string, options?: GetConfigOptions): ProjectConfig;
interface ProjectConfig {
exp: ExpoConfig;
mods?: ModConfig | null;
pkg: PackageJSONConfig;
rootConfig: AppJSONConfig;
staticConfigPath: string | null;
dynamicConfigPath: string | null;
dynamicConfigObjectType: string | null;
hasUnusedStaticConfig: boolean;
}
interface GetConfigOptions {
isPublicConfig?: boolean;
isModdedConfig?: boolean;
skipSDKVersionRequirement?: boolean;
skipPlugins?: boolean;
strict?: boolean;
}Utilities for resolving entry points and file extensions in Expo projects, with support for monorepos and platform-specific files.
function resolveEntryPoint(
projectRoot: string,
options?: { platform?: string; pkg?: PackageJSONConfig }
): string;
function getBareExtensions(
platforms: string[],
languageOptions?: LanguageOptions
): string[];Automatic detection and validation of Expo SDK versions from configuration or installed packages.
function getExpoSDKVersion(
projectRoot: string,
exp?: Pick<ExpoConfig, 'sdkVersion'>
): string;Type definitions and interfaces for build caching systems used in Expo development workflows.
interface BuildCacheProvider<T = any> {
plugin: BuildCacheProviderPlugin<T>;
options: T;
}
type RunOptions = AndroidRunOptions | IosRunOptions;// Core configuration types
interface ExpoConfig {
name?: string;
slug?: string;
version?: string;
sdkVersion?: string;
platforms?: Platform[];
description?: string;
plugins?: any[];
// ... extensive additional properties
}
interface PackageJSONConfig {
dependencies?: Record<string, string>;
[key: string]: any;
}
interface AppJSONConfig {
expo: ExpoConfig;
[key: string]: any;
}
// Utility types
type Platform = 'android' | 'ios' | 'web';
type ProjectTarget = 'managed' | 'bare';
interface ConfigFilePaths {
staticConfigPath: string | null;
dynamicConfigPath: string | null;
}
// Error handling
class ConfigError extends Error {
readonly name: 'ConfigError';
readonly isConfigError: true;
code: ConfigErrorCode;
cause?: Error;
}
type ConfigErrorCode =
| 'NO_APP_JSON'
| 'NOT_OBJECT'
| 'NO_EXPO'
| 'MODULE_NOT_FOUND'
| 'DEPRECATED'
| 'INVALID_MODE'
| 'INVALID_FORMAT'
| 'INVALID_PLUGIN'
| 'INVALID_CONFIG'
| 'ENTRY_NOT_FOUND';