Skip to main content

expo-modules-core

Version: 55.0.9 The core of Expo Modules architecture. This package provides the foundational APIs and infrastructure for creating native modules that work seamlessly with React Native and Expo.

Overview

expo-modules-core enables developers to write native modules in Swift (iOS) and Kotlin (Android) with a modern, declarative API. It eliminates boilerplate code and provides automatic type conversion, event handling, and view management.

Installation

In bare React Native projects:

Key Features

  • Modern Native APIs: Write modules in Swift and Kotlin
  • Type Safety: Automatic type conversion between JavaScript and native
  • View Components: Easy creation of native UI components
  • Event Handling: Built-in event emitter system
  • Shared Objects: Pass complex objects between JS and native
  • Auto-Linking: Automatic module discovery and registration

Module API Architecture

The module API provides a declarative way to define native functionality:

iOS (Swift)

Android (Kotlin)

JavaScript Usage

Creating Native View Components

iOS View (Swift)

Android View (Kotlin)

React Component

Event Handling

Native Event Emission

iOS:
Android:

JavaScript Event Subscription

Shared Objects

Shared Objects allow passing complex, stateful objects between JavaScript and native code:

Native Implementation (Swift)

JavaScript Usage

Type Conversions

Automatic type conversion between JavaScript and native:

Lifecycle Methods

Error Handling

Throwing Errors (Swift)

Catching Errors (JavaScript)

Creating Custom Modules

1. Create Module Package

2. Implement Native Code

Edit ios/MyModule.swift and android/src/main/java/expo/modules/mymodule/MyModule.kt

3. Export JavaScript API

Create src/index.ts:

4. Test & Publish

API Reference

Module Definition

string
required
The name of the module as it appears in JavaScript
object
Static values exported to JavaScript
function
Synchronous function callable from JavaScript
function
Asynchronous function that returns a Promise
string[]
List of event names this module can emit

View Definition

property
Defines a prop that can be set from React
string[]
Events that the view can emit

Resources