Skip to main content
The expo-modules-core package is the foundation of Expo Modules architecture, providing the infrastructure for creating native modules with a modern, type-safe API.

Installation

This package is typically installed automatically as a dependency of the expo package.

Overview

Expo Modules Core provides:
  • A modern API for writing native modules
  • Type-safe bridge between JavaScript and native code
  • Event emitting capabilities
  • Shared objects for cross-JSI communication
  • Platform abstractions
  • Permission management interfaces

Core APIs

EventEmitter

A class for creating objects that emit events to JavaScript. Native modules and shared objects can emit events that React components can listen to.

Type Definition

Usage

EventSubscription

Returned by addListener(), provides a way to remove the listener.
() => void
Removes the event listener. After calling this, the listener will no longer receive events.

NativeModule

Base class for native modules, providing the foundation for Expo’s module system. Native modules written with Expo Modules API automatically inherit from this class.

Accessing Native Modules

SharedObject

Represents an instance of a native shared object that exists in the native memory and can be passed between different independent libraries. Allows for sharing native object instances across the JSI boundary.

Key Features

  • Lives in native memory
  • Can be passed to any native module
  • Supports event emitting
  • Automatic lifecycle management
  • Type-safe in TypeScript

Usage

SharedRef

A mutable ref that holds a reference to a shared object. Unlike SharedObject, the reference itself can be updated.

Module Registration

requireNativeModule

Imports a native module by name. Throws an error if the module is not found.
string
required
Name of the native module to import.
ModuleType
The native module object with all its methods and properties.
This function throws an error if the module cannot be found. Use requireOptionalNativeModule for optional dependencies.

requireOptionalNativeModule

Imports a native module by name. Returns null if the module is not found instead of throwing.
string
required
Name of the native module to import.
ModuleType | null
The native module object or null if not found.

requireNativeViewManager

Requires a native view manager for creating native UI components.
string
required
Name of the native view manager.

registerWebModule

Registers a web-specific implementation of a module.
string
required
Name of the module to register.
object
required
The web implementation of the module.

Platform Utilities

Platform

Provides information about the current platform.
'ios' | 'android' | 'web'
The current platform operating system.
string | number
The OS version.
function
Selects a value based on the platform.

Permission Management

PermissionsInterface

Interface for implementing permission requests in native modules.

usePermissions

React hook for managing permissions.

Error Classes

CodedError

Error class with an error code for better error handling.
string
required
Unique error code.
string
required
Human-readable error message.

UnavailabilityError

Thrown when a native module or feature is unavailable on the current platform.

Reload Utilities

reloadAppAsync

Reloads the JavaScript bundle without restarting the native app.

UUID Generation

uuid

Generates a UUID (Universally Unique Identifier).

Type Definitions

ProxyNativeModule

Type for native modules accessed through the bridge proxy.

Typed Arrays

Support for typed arrays across the JSI bridge:
  • Int8Array
  • Int16Array
  • Int32Array
  • Uint8Array
  • Uint8ClampedArray
  • Uint16Array
  • Uint32Array
  • Float32Array
  • Float64Array

Writing Native Modules

While expo-modules-core provides the JavaScript APIs, native modules are written using the Expo Modules API on iOS (Swift) and Android (Kotlin).

Module Definition (iOS - Swift)

Module Definition (Android - Kotlin)

Legacy APIs

LegacyEventEmitter

Deprecated event emitter API. Use EventEmitter instead.

NativeModulesProxy

Direct access to the native modules proxy. Generally, you should use requireNativeModule instead.

Source Code

View the source code on GitHub: expo-modules-core