expo-module – skill Lập trình cho agent AI
Hướng dẫn tạo và viết module và view native của Expo bằng Expo Modules API (Swift, Kotlin, TypeScript). Bao gồm DSL định nghĩa module, native views, shared objects, config plugins, lifecycle hooks, autolinking và hệ thống kiểu.
Cài skill expo-module bằng một lệnh
Chọn công cụ bạn đang dùng, copy lệnh và dán vào terminal. Skill sẽ nằm trong thư mục skills của công cụ đó và sẵn sàng dùng ở phiên làm việc tiếp theo.
Claude Code
mkdir -p ~/.claude/skills && curl -fsSL https://skill.dn1nguoi.com/z/expo-module-c5c21.tgz | tar xz -C ~/.claude/skills
Gọi trong Claude Code: /expo-module – rồi mô tả công việc bạn muốn làm.
Codex
mkdir -p ~/.codex/skills && curl -fsSL https://skill.dn1nguoi.com/z/expo-module-c5c21.tgz | tar xz -C ~/.codex/skills
Gọi trong Codex: $expo-module – rồi mô tả công việc bạn muốn làm.
Hermes Agent
mkdir -p ~/.hermes/skills && curl -fsSL https://skill.dn1nguoi.com/z/expo-module-c5c21.tgz | tar xz -C ~/.hermes/skills
Gọi trong Hermes Agent: /expo-module – rồi mô tả công việc bạn muốn làm.
DeepSeek
mkdir -p ~/.deepcode/skills && curl -fsSL https://skill.dn1nguoi.com/z/expo-module-c5c21.tgz | tar xz -C ~/.deepcode/skills
Gọi trong DeepSeek: /expo-module – rồi mô tả công việc bạn muốn làm.
Nội dung SKILL.md
Nội dung SKILL.md gốc bằng tiếng Anh.
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 behaviorNative integration limits
Pin the scaffold and Expo SDK versions and verify available CLI options before running them. These native modules require a development/rebuilt native app; adding native code is not an Expo Go or OTA-only update. Preserve native modifications before prebuild, request platform permissions with accurate purpose strings, and validate native inputs, lifecycle cleanup and thread affinity on both platforms. Snippets omit imports/helpers and are not a compiled package.
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](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 modeexpo.autolinking.nativeModulesDiradd-platform-supportbehavior 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
--platformintentionally instead of relying on defaults - use
--featuresto 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.
ViewEventimpliesView.- Local modules do not generate an
index.tsbarrel by default. Use--barrelonly if you want one. - In non-interactive local scaffolding, pass the positional slug or path explicitly.
--namechanges the native class name, not the folder name. - Local modules live in
expo.autolinking.nativeModulesDirwhen configured, otherwise inmodules/. - 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.
Limitations
- Use this skill only when the task clearly matches its upstream product or API scope.
- Verify commands, API behavior, pricing, quotas, credentials, and deployment effects against current official documentation before making changes.
- Do not treat generated examples as a substitute for environment-specific tests, security review, or user approval for destructive or costly actions.
Skill liên quan
- zarr-python – Lưu trữ và truy vấn mảng khoa học N chiều phân khối (chunked) với Zarr-Python 3, bao gồm…
- faf-go – Phỏng vấn có hướng dẫn để đạt Gold Code (100% sẵn sàng cho AI). Dùng khi giúp người dùng…
- web3-testing – Kiểm thử smart contract toàn diện bằng Hardhat và Foundry với unit test, integration…
- roast – Dùng khi ai đó yêu cầu roast một ý tưởng, kiểm tra áp lực hoặc stress-test một ý tưởng…
- fastapi-pro – Xây dựng API bất đồng bộ hiệu năng cao với FastAPI, SQLAlchemy 2.0 và Pydantic V2. Thành…
- fastapi-templates – Tạo dự án FastAPI sẵn sàng production với mẫu async, dependency injection và xử lý lỗi…
- weekly-review-planning – Reset đầu tuần: cam kết, công việc bị đình trệ, kế hoạch tuần tới.
- sample-text-processor – Skill mẫu cấp BASIC, dùng làm fixture cho skill-tester. Đếm từ và ký tự, áp dụng các…