jonluca/palate / .agents/skills/expo-module
expo-module
VerifiedFramework (OSS). 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.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 6.4 KB |
| agents/openai.yaml | config | 367 B |
| references/config-plugin.md | markdown | 2.0 KB |
| references/create-expo-module.md | markdown | 9.8 KB |
| references/lifecycle.md | markdown | 3.7 KB |
| references/module-config.md | markdown | 1.7 KB |
| references/native-module.md | markdown | 5.7 KB |
| references/native-view.md | markdown | 3.5 KB |
references/native-view.md
View on GitHub# Native View Reference
Native views let you render platform UI components (UIView on iOS, Android View on Android) as React components.
## Defining a View
**Swift:**
```swift
public class MyViewModule: Module {
public func definition() -> ModuleDefinition {
Name("MyView")
View(MyNativeView.self) {
Prop("title") { (view: MyNativeView, title: String) in
view.titleLabel.text = title
}
Events("onPress", "onLoad")
AsyncFunction("reset") { (view: MyNativeView) in
view.reset()
}
}
}
}
class MyNativeView: ExpoView {
let titleLabel = UILabel()
required init(appContext: AppContext) {
super.init(appContext: appContext)
clipsToBounds = true
addSubview(titleLabel)
}
override func layoutSubviews() {
super.layoutSubviews()
titleLabel.frame = bounds
}
}
```
**Kotlin:**
```kotlin
class MyViewModule : Module() {
override fun definition() = ModuleDefinition {
Name("MyView")
View(MyNativeView::class) {
Prop("title") { view: MyNativeView, title: String ->
view.titleView.text = title
}
Events("onPress", "onLoad")
AsyncFunction("reset") { view: MyNativeView ->
view.reset()
}
}
}
}
class MyNativeView(context: Context, appContext: AppContext) : ExpoView(context, appContext) {
val titleView = TextView(context).also {
addView(it, LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT))
}
}
```
**TypeScript:**
```typescript
import { requireNativeView } from "expo";
export type MyViewProps = {
title?: string;
onPress?: (event: { nativeEvent: { x: number; y: number } }) => void;
onLoad?: () => void;
} & ViewProps;
const NativeView = requireNativeView<MyViewProps>("MyView");
export function MyView(props: MyViewProps) {
return <NativeView {...props} />;
}
```
## View Event Dispatching
**Swift:**
```swift
class MyNativeView: ExpoView {
let onPress = EventDispatcher()
func handleTap(at point: CGPoint) {
onPress(["x": point.x, "y": point.y])
}
}
```
**Kotlin:**
```kotlin
class MyNativeView(context: Context, appContext: AppContext) : ExpoView(context, appContext) {
private val onPress by EventDispatcher()
fun handleTap(x: Float, y: Float) {
onPress(mapOf("x" to x, "y" to y))
}
}
```
## View Lifecycle
```swift
// Called after all props have been set
OnViewDidUpdateProps { (view: MyNativeView) in
view.applyChanges()
}
```
```kotlin
// Android only - called when view is no longer used
OnViewDestroys { view: MyNativeView ->
view.cleanup()
}
```
## AsyncFunction on Views
Functions defined inside `View` are accessible via React ref:
```typescript
const ref = useRef<MyView>(null);
// Call native function
await ref.current?.reset();
```
## PropGroup (Android)
Batch-register multiple props with shared setter logic:
```kotlin
View(MyNativeView::class) {
PropGroup("border", "width" to Float::class, "color" to Int::class) { view, index, value ->
when (index) {
0 -> view.borderWidth = value as Float
1 -> view.borderColor = value as Int
}
}
}
```
## GroupView (Android)
Enable view group functionality for managing child views:
```kotlin
View(MyContainerView::class) {
GroupView {
AddChildView { parent, child, index -> parent.addView(child, index) }
GetChildCount { parent -> parent.childCount }
GetChildViewAt { parent, index -> parent.getChildAt(index) }
RemoveChildView { parent, child -> parent.removeView(child) }
RemoveChildViewAt { parent, index -> parent.removeViewAt(index) }
}
}
```
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementation | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirements | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallback | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |