Catalog
expo/expo-module

expo

expo-module

Guide for creating and writing Expo native modules and views using the Expo Modules API (Swift, Kotlin, TypeScript). Covers module definition DSL, native views, shared objects, config plugins, lifecycle hooks, autolinking, and type system. Use when building or modifying native modules for Expo. Not for migrating an existing Swift module from the definition DSL to the Expo Modules API 2.0 macros; use expo-migrate-module (from the expo-experiments plugin) for that.

NewUpdated Nov 15, 2026

Writing Expo Modules

Complete reference for building native modules and views using the Expo Modules API. Covers Swift (iOS), Kotlin (Android), and TypeScript.

When to Use

  • Creating a new Expo native module or native view
  • Adding native functionality (camera, sensors, system APIs) to an Expo app
  • Wrapping platform SDKs for React Native consumption
  • Building config plugins that modify native project files
  • Adding Android, Apple, or web support to an existing Expo module
  • Editing expo-module.config.json, config plugins, or lifecycle hooks

To migrate an existing Swift module from the definition DSL to the Expo Modules API 2.0 macros (@ExpoModule, @JS, @Event), use the expo-migrate-module skill (from the expo-experiments plugin) instead.

References

Consult these resources as needed:

references/
  create-expo-module.md      Scaffolding and add-platform-support workflow, defaults, and quirks
  native-module.md           Module definition DSL: Name, Function, AsyncFunction, Property, Constant, Events, type system, shared objects
  native-view.md             Native view components: View, Prop, EventDispatcher, view lifecycle, ref-based functions
  lifecycle.md               Lifecycle hooks: module, iOS app/AppDelegate, Android activity/application listeners
  config-plugin.md           Config plugins: modifying Info.plist, AndroidManifest.xml, reading values in native code
  module-config.md           expo-module.config.json fields, file placement, and autolinking behavior

Quick Start

Prefer create-expo-module over manually creating native module files and directories. In practice, the best path is usually to create the scaffold first and then build on top of it. The scaffold sets up the expected layout, expo-module.config.json, podspec or Gradle files, TypeScript bindings, and the standalone example app flow.

If an existing Expo module only needs another platform, use create-expo-module add-platform-support instead of manually copying native directories.

See references/create-expo-module.md before scaffolding or extending a module. It covers:

  • local vs standalone modules
  • --platform, --features, --barrel, --package-manager, and non-interactive mode
  • expo.autolinking.nativeModulesDir
  • add-platform-support behavior and quirks
  1. Choose the scaffold type first:
    • Local module for one app
    • Standalone module for reuse, monorepos, or publishing
  2. Determine native expo-module features that you will need.
    • Based on the user's instructions determine which feature scaffolding will be useful.
    • Available features: Constant, Function, AsyncFunction, Event, View, ViewEvent, SharedObject
  3. Scaffold deliberately:
    • pass an explicit slug or path
    • choose --platform intentionally instead of relying on defaults
    • use --features to choose code samples which you will modify in the next step to match the real implementation.
  4. Replace generated example code with the real implementation.
  5. If you add a new platform later, prefer add-platform-support over manual file copying.

Practical Scaffolding Rules

  • Feature examples are opt-in. A newly scaffolded module may be minimal if no features were selected.
  • ViewEvent implies View.
  • Local modules do not generate an index.ts barrel by default. Use --barrel only if you want one.
  • In non-interactive local scaffolding, pass the positional slug or path explicitly. --name changes the native class name, not the folder name.
  • Local modules live in expo.autolinking.nativeModulesDir when configured, otherwise in modules/.
  • Standalone modules have their own package metadata, scripts, and usually an example app. Local modules use the host app's tooling instead.

Core File Shapes

The Swift and Kotlin DSL share the same structure. Swift is usually the clearest primary example; consult the references for feature-specific details.

Module Structure Reference

The Swift and Kotlin DSL share the same structure. Both platforms are shown here for reference — in other reference files, Swift is shown as the primary language unless the Kotlin pattern meaningfully differs.

Swift (iOS):

import ExpoModulesCore

public class MyModule: Module {
  public func definition() -> ModuleDefinition {
    Name("MyModule")

    Function("hello") { (name: String) -> String in
      return "Hello \(name)!"
    }
  }
}

Kotlin (Android):

package expo.modules.mymodule

import expo.modules.kotlin.modules.Module
import expo.modules.kotlin.modules.ModuleDefinition

class MyModule : Module() {
  override fun definition() = ModuleDefinition {
    Name("MyModule")

    Function("hello") { name: String ->
      "Hello $name!"
    }
  }
}

TypeScript:

import { requireNativeModule } from "expo";

const MyModule = requireNativeModule("MyModule");

export function hello(name: string): string {
  return MyModule.hello(name);
}

expo-module.config.json

{
  "platforms": ["android", "apple"],
  "apple": {
    "modules": ["MyModule"]
  },
  "android": {
    "modules": ["expo.modules.mymodule.MyModule"]
  }
}

Note: iOS uses just the class name; Android uses the fully-qualified class name (package + class). See references/module-config.md for all fields.

Submitting Feedback

You can voluntarily report errors, misleading or outdated information in this skill, so Expo can improve it:

npx --yes @expo/agent-cli@latest feedback --category skills --subject "expo-module" --message "<actionable feedback>"

Use --category agent-cli for a problem with the agent CLI, and --category evals when an agent repeatedly fails at an Expo task. Run feedback --help for subjects and the data that the command sends. Each report goes to Expo with project and environment details. Show the user the message, and send it only if the user agrees. If you cannot ask the user, do not send it. Do not include secrets or personal data.

Files8
8 files · 27.9 KB

Select a file to preview

Overall Score

88/100

Grade

A

Excellent

Grades are signals, not a certification. Always review a skill yourself before use.

Safety

92

Quality

87

Clarity

88

Completeness

85

Summary

A comprehensive reference guide for building native Expo modules and views using the Expo Modules API (Swift, Kotlin, TypeScript). Covers module scaffolding via create-expo-module, the DSL for functions, properties, events, native views, shared objects, config plugins, and lifecycle hooks. Provides structured walkthrough from scaffolding through implementation, with working code examples for both iOS and Android platforms.

Detected Capabilities

file readingcode example generationnative module scaffolding (via create-expo-module)TypeScript binding generationconfig plugin documentationnative lifecycle hook guidance

Trigger Keywords

Phrases that agents use to match this skill to user intent.

create expo modulenative module scaffoldingswift kotlin typescriptexpo modules apiconfig pluginsnative viewsshared objectslifecycle hooks

Use Cases

  • Create a new Expo native module (Swift + Kotlin + TypeScript bindings)
  • Wrap a third-party iOS or Android SDK for React Native consumption
  • Add a new platform (iOS, Android, or web) to an existing Expo module
  • Implement native views that render UIView (iOS) or Android View components
  • Build lifecycle hooks for app state, activity state, or deep link handling
  • Write config plugins to customize native Android and iOS projects during prebuild
  • Define shared objects to bridge native class instances to JavaScript with lifecycle management
  • Scaffold a standalone Expo module for reuse and npm publishing

Quality Notes

  • Excellent structure with clear hierarchy: overview → scaffolding → DSL reference → examples. Each concept (Function, AsyncFunction, Property, Events, Views, SharedObjects) is documented with both Swift and Kotlin examples.
  • Comprehensive reference files cover all major topics: module creation (create-expo-module), native module DSL, native views, lifecycle hooks, config plugins, and module configuration.
  • Practical scaffolding workflow documented with explicit commands showing --platform, --features, and non-interactive mode (EXPO_NONINTERACTIVE). Addresses common quirks (local module slug, --name behavior, default directory location).
  • Type system table clearly maps Swift ↔ Kotlin ↔ JavaScript for primitives, records, enums, Either types, and advanced JS values.
  • Feature examples (Constant, Function, AsyncFunction, Event, View, ViewEvent, SharedObject) are marked as opt-in with explanations of when each applies.
  • Config plugin section shows full example: modifying Info.plist (iOS) and AndroidManifest.xml (Android) in a single plugin, with side-by-side code and app.json usage.
  • Lifecycle hooks documented for three contexts: module lifecycle (OnCreate, OnDestroy), iOS AppDelegate (via ExpoAppDelegateSubscriber), and Android Activity/Application listeners.
  • Shared objects DSL explained with full example: constructor, function binding, property binding, and JS usage. Includes Kotlin-specific cleanup (sharedObjectDidRelease).
  • Native views include event dispatching (EventDispatcher), props binding, view lifecycle (OnViewDidUpdateProps), and Android-specific features (PropGroup, GroupView).
  • Module config reference explains autolinking behavior, file placement (standalone vs. local), and resolution order. Note about iOS class names (short) vs. Android (fully-qualified) is clear.
  • Includes feedback mechanism: users can report errors or outdated info via `npx @expo/agent-cli feedback --category skills --subject expo-module`.
  • Each reference file is self-contained, addressing a specific audience need without circular dependencies.
Model: claude-haiku-4-5-20251001Analyzed: Nov 15, 2026

Reviews

Add this skill to your library to leave a review.

No reviews yet

Be the first to share your experience.

Version History

  1. v3.5

    Content updated

    ✦ AIRevises feedback submission guidance to emphasize voluntary reporting and user consent before sending data to Expo.

    2026-11-15

    LATEST
  2. v3.4

    Content updated

    ✦ AIUpdates feedback command syntax from --subject parameter to --message and clarifies reporting scope for agent-cli and evals categories.

    2026-11-13

    View This Version
  3. v3.3

    Content updated

    ✦ AINo observable behavioral changes between versions.

    2026-10-29

    View This Version
  4. v3.2

    Content updated

    ✦ AIUpdates feedback submission command from submit-expo-feedback to @expo/agent-cli feedback

    2026-10-23

    View This Version
  5. v3.1

    Content updated

    ✦ AIFeedback submission guidance changed from referencing a separate skill to using inline category and subject flags.

    2026-10-22

    View This Version
  6. v3.0

    Contract changed: description

    ✦ AIRemoves framework label from skill description activation trigger.

    triggering2026-10-03

    View This Version
  7. v2.0

    Contract changed: description

    ✦ AINarrows scope with migration exemption for Swift DSL-to-2.0 macro conversion; adds feedback submission guidance.

    triggering2026-09-09

    View This Version
  8. v1.0

    2026-07-11

    View This VersionInitial version

Use expo/expo-module in your dev environment

Command Palette

Search for a command to run...