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 Oct 3, 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

If you encounter errors, misleading or outdated information in this skill, report it so Expo can improve:

npx --yes submit-expo-feedback@latest --category skills --subject "expo-module" "<actionable feedback>"

Only submit when you have something specific and actionable to report. Include as much relevant context as possible. If an AI agent repeatedly failed or the user had to take over an Expo task, load the expo-skill-feedback skill and follow its eval-candidate flow instead of reusing the command above.

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

89

Completeness

82

Summary

This skill provides a comprehensive reference guide for building Expo native modules and views using Swift, Kotlin, and TypeScript. It covers the module definition DSL, native views, shared objects, config plugins, lifecycle hooks, autolinking, and the type system. The skill includes well-structured reference documents for scaffolding workflows, native module patterns, native view components, lifecycle hooks, config plugins, and module configuration, supported by practical code examples for all platforms.

Detected Capabilities

Code generation (module scaffolding)File writing (TypeScript, Swift, Kotlin templates)Structured code examples (DSL patterns)Reference documentationType system guidanceBuild system configuration (expo-module.config.json, podspec, Gradle)CLI command guidance (create-expo-module, npx commands)

Trigger Keywords

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

create expo modulenative module swift kotlinexpo native viewconfig plugin prebuildexpo lifecycle hooksshared objects bridgeautolinking setupexpo module config

Use Cases

  • Creating a new Expo native module from scratch using create-expo-module
  • Implementing native functions and events in Swift/Kotlin and exposing them to JavaScript
  • Building native view components that render platform-specific UI (UIView on iOS, View on Android)
  • Extending existing Expo modules with additional platforms using add-platform-support
  • Defining config plugins that modify Info.plist and AndroidManifest.xml during prebuild
  • Setting up lifecycle hooks for module initialization, app foreground/background, and activity lifecycle
  • Configuring autolinking and module registration via expo-module.config.json
  • Creating shared objects that bridge native class instances to JavaScript with automatic lifecycle management

Quality Notes

  • Excellent cross-platform coverage: Swift, Kotlin, and TypeScript examples are provided for nearly every pattern, with platform-specific syntax differences clearly noted
  • Strong reference document organization: each major concern (scaffolding, native modules, native views, lifecycle, config plugins, module config) has a dedicated, well-structured reference file
  • Comprehensive type system documentation: primitive types, records, enums, union types (Either), JavaScript values, and shared objects are all clearly defined with examples
  • Practical workflow guidance: the 'Recommended Workflow' section provides step-by-step scaffolding best practices, including deliberate feature selection and template generation strategies
  • Clear DSL structure reference: the core module, view, and shared object patterns are shown for both Swift and Kotlin side-by-side, reducing cognitive load
  • Excellent edge case coverage: lifecycle hooks, OnStartObserving/OnStopObserving event scoping, AppDelegate subscribers, and Android listener patterns are all well-documented
  • Autolinking resolution order is clearly documented, helping developers understand module discovery precedence
  • Useful CLI option tables with explanations of local vs standalone module differences and platform behavior
  • Feedback mechanism provided: users can report skill errors or outdated information using the submit-expo-feedback command
  • Well-scoped out-of-scope content: explicitly states that migration from definition DSL to Expo Modules API 2.0 macros should use expo-migrate-module instead
Model: claude-haiku-4-5-20251001Analyzed: Oct 3, 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.0

    Contract changed: description

    ✦ AIRemoves framework label from skill description activation trigger.

    triggering2026-10-03

    LATEST
  2. 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
  3. 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...