expo package is the core of the Expo SDK, providing essential functionality for Expo applications.
Installation
Overview
Theexpo package serves as the entry point for Expo applications and provides:
- Core module APIs (EventEmitter, SharedObject, NativeModule)
- Root component registration
- Development tools integration
- Native module access utilities
- React hooks for event handling
Main Exports
registerRootComponent
Sets the initial React component to render natively in your app’s root React Native view on Android, iOS, tvOS and web.The React component class that renders the rest of your app.
- Invokes React Native’s
AppRegistry.registerComponent - On web, invokes
AppRegistry.runApplicationto render to the rootindex.htmlfile - Polyfills the
process.nextTickfunction globally - In development, adds Fast Refresh and bundle splitting indicators
- In development, validates
expo-updatesconfiguration
This is typically used in your
index.js or App.js file as the entry point.Core Classes
These classes are re-exported fromexpo-modules-core for convenience.
EventEmitter
A class for objects that emit events. Native modules and shared objects can extend this class to provide event emitting capabilities.SharedObject
Represents an instance of a native shared object that can be passed between different independent libraries. Allows for sharing native object instances across the JSI boundary.SharedRef
A mutable ref that can hold a reference to a shared object and allows for updating that reference across the native boundary.NativeModule
Base class for native modules to inherit from, providing the foundation for Expo’s module system.Module Access Functions
requireNativeModule
Imports a native module registered with the given name.Name of the requested native module.
Object representing the native module.
requireOptionalNativeModule
Same asrequireNativeModule, but returns null when the module cannot be found instead of throwing an error.
Name of the requested native module.
Object representing the native module or
null if not found.requireNativeView
Requires a native view manager for creating native UI components.registerWebModule
Registers a web implementation for a native module, allowing for platform-specific implementations.React Hooks
useEvent
React hook that listens to events emitted by an object and returns the latest event parameter.An object that emits events (native module, shared object, or EventEmitter instance).
Name of the event to listen to.
Initial value to use until the first event is received.
useEventListener
React hook that listens to events and calls a listener function whenever a new event is dispatched.An object that emits events.
Name of the event to listen to.
Function to call when the event is dispatched.
Utility Functions
reloadAppAsync
Reloads the app, similar to refreshing a web page.disableErrorHandling
Disables Expo’s error handling overlay (useful for custom error boundaries).isRunningInExpoGo
Checks if the app is running inside Expo Go.true if running in Expo Go, false otherwise.getExpoGoProjectConfig
Gets the project configuration when running in Expo Go.Worklets
installOnUIRuntime
Installs a worklet on the UI runtime for use with react-native-reanimated.Included Dependencies
Theexpo package includes several core dependencies:
expo-asset- Asset system for managing and loading assetsexpo-constants- System and app constantsexpo-file-system- File system accessexpo-font- Custom font loadingexpo-keep-awake- Prevents the screen from sleeping@expo/vector-icons- Icon library
CLI Integration
Theexpo package includes the Expo CLI as a dependency. When you install expo, you get access to:
Metro Configuration
The package provides a Metro configuration helper:TypeScript
Theexpo package includes full TypeScript definitions. Import types from expo-modules-core/types: