expo-module

von expo

Leitfaden zum Erstellen und Schreiben von nativen Expo-Modulen und -Ansichten mit der Expo Modules API (Swift, Kotlin, TypeScript). Behandelt die Moduldefinitions-DSL, native…

npx skills add https://github.com/expo/skills --skill expo-module

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

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

Recommended Workflow

  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.

Mehr Skills von expo

android-e2e-testing
expo
Testen Sie Expo Router-Funktionen auf Android-Emulatoren mit ADB. Verwenden Sie dies nach der Implementierung nativer Android-Funktionen oder bei der Überprüfung des UI-Verhaltens auf Android.
official
deep-code-review
expo
Tiefgehende, designorientierte Code-Review – versteht den Codebase-Kontext, bevor PR-Änderungen bewertet werden, und veröffentlicht strukturiertes Feedback auf GitHub
official
building-native-ui
expo
Vollständiger Leitfaden zum Erstellen nativer Expo-Apps mit Routing, Styling, Komponenten und Plattformkonventionen. Behandelt Expo Router-Grundlagen, native Tabs, Stack-Navigation, Modals und Formularblätter mit detaillierten Routenstrukturkonventionen. Enthält Styling-Regeln gemäß den Apple Human Interface Guidelines: Flexbox-Layouts, Safe-Area-Handling, Animationen, Schatten via CSS boxShadow und responsive Designmuster. Dokumentiert Bibliothekspräferenzen (expo-image für SF Symbols, expo-audio, expo-video,...
official
eas-update-insights
expo
Überprüfen Sie den Zustand veröffentlichter EAS-Updates: Absturzraten, Installations-/Startzahlen, eindeutige Nutzer, Payload-Größe und die Aufteilung zwischen eingebetteten und OTA-Nutzern pro…
official
expo-api-routes
expo
API-Routen in Expo Router für serverseitige Logik, Geheimnisse und Drittanbieter-Integrationen auf EAS Hosting. Erstelle Routen mit +api.ts-Suffix im App-Verzeichnis; exportiere benannte Funktionen für HTTP-Methoden (GET, POST, PUT, DELETE). Verarbeite Abfrageparameter, Header, JSON-Bodies und dynamische Routensegmente; füge CORS-Header für Web-Clients hinzu. Greife auf serverseitige Geheimnisse über process.env zu; setze Variablen lokal in .env oder über eas env:create für die Produktion. Stelle auf EAS Hosting (Cloudflare Workers) mit eas bereit...
official
expo-cicd-workflows
expo
Schreibt und validiert EAS CI/CD-Workflow-YAML-Dateien für Expo-Projekte. Ruft das neueste JSON-Schema von der Expo-API ab, um sicherzustellen, dass Job-Typen, Parameter, Trigger und Runner-Konfigurationen aktuell sind. Unterstützt dynamische Ausdrücke mit der ${{ }}-Syntax und Kontexten für GitHub-Ereignisse, Workflow-Eingaben, Job-Ausgaben und Schrittergebnisse. Enthält ein integriertes Validierungsskript, das die Workflow-Struktur gegen das Schema prüft und Fehler vor der Bereitstellung meldet. Bietet Referenzdokumentation für Syntax,...
official
expo-deployment
expo
Automatisierte Bereitstellung von Expo-Apps im iOS App Store, Android Play Store, Webhosting und Vorschauumgebungen. Unterstützt Produktions-Builds und Einreichungen für iOS (App Store und TestFlight) und Android (Google Play Store) mit einzelnen Befehlen. Enthält EAS Hosting für Web-Bereitstellungen mit automatischen PR-Vorschau-URLs und Produktionsdomain-Unterstützung. Bietet CI/CD-Workflow-Automatisierung über EAS Workflows für getriggerte Builds und Einreichungen bei Code-Pushes. Automatische Versionsverwaltung mit Remote...
official
expo-dev-client
expo
Erstelle benutzerdefinierte Expo-Entwicklungsclients zum Testen von nativem Code auf physischen Geräten über EAS Build oder lokal. Nur erforderlich bei Verwendung benutzerdefinierter nativer Module, Apple-Ziele (Widgets, App Clips) oder nativer Drittanbieter-Code, der nicht in Expo Go verfügbar ist; versuche zuerst Expo Go mit npx expo start. Unterstützt Cloud-Builds mit automatischer TestFlight-Einreichung oder lokale Builds auf Ihrem Rechner, die .ipa (iOS) oder .apk/.aab (Android) Dateien ausgeben. Erfordert eas.json-Konfiguration mit einem Entwicklungsprofil, das... festlegt.
official