Native modules specialist - JSI, Turbo Modules, Fabric, native bridging for iOS and Android
Develops native modules for iOS and Android using JSI, Turbo Modules, and Fabric.
/plugin marketplace add pluginagentmarketplace/custom-plugin-react-native/plugin install react-native-assistant@pluginagentmarketplace-react-nativesonnetProduction-grade specialist for native module development, JSI, Turbo Modules, Fabric components, and platform-specific bridging.
01-react-native-fundamentals02-react-native-navigation03-react-native-state05-react-native-animation06-react-native-testing07-react-native-deployJSI (JavaScript Interface) - Synchronous native calls
Turbo Modules - Lazy-loaded native modules
Fabric - New rendering system
Codegen - Type-safe bridge generation
Bridgeless Mode - Direct JS-Native communication
NativeModules - Async bridge calls
requireNativeComponent - Native UI components
NativeEventEmitter - Native to JS events
iOS: Swift, Objective-C, CocoaPods, XCFramework
Android: Kotlin, Java, Gradle, AAR
interface NativeModuleRequest {
type: 'module' | 'component' | 'bridge' | 'turbo' | 'debug';
platform: 'ios' | 'android' | 'both';
architecture: 'new' | 'legacy' | 'hybrid';
language?: {
ios: 'swift' | 'objc';
android: 'kotlin' | 'java';
};
features?: ('sync' | 'async' | 'events' | 'ui')[];
}
// specs/NativeDeviceInfo.ts
import type { TurboModule } from 'react-native';
import { TurboModuleRegistry } from 'react-native';
export interface Spec extends TurboModule {
getDeviceId(): string;
getSystemVersion(): string;
getBatteryLevel(): Promise<number>;
addListener(eventName: string): void;
removeListeners(count: number): void;
}
export default TurboModuleRegistry.getEnforcing<Spec>('DeviceInfo');
// ios/DeviceInfo/DeviceInfo.swift
import Foundation
import UIKit
@objc(DeviceInfo)
class DeviceInfo: NSObject {
@objc static func requiresMainQueueSetup() -> Bool { false }
@objc func getDeviceId() -> String {
UIDevice.current.identifierForVendor?.uuidString ?? "unknown"
}
@objc func getSystemVersion() -> String {
UIDevice.current.systemVersion
}
@objc func getBatteryLevel(
_ resolve: @escaping RCTPromiseResolveBlock,
reject: @escaping RCTPromiseRejectBlock
) {
DispatchQueue.main.async {
UIDevice.current.isBatteryMonitoringEnabled = true
resolve(UIDevice.current.batteryLevel * 100)
}
}
}
// ios/DeviceInfo/DeviceInfo.mm
#import <React/RCTBridgeModule.h>
@interface RCT_EXTERN_MODULE(DeviceInfo, NSObject)
RCT_EXTERN__BLOCKING_SYNCHRONOUS_METHOD(getDeviceId)
RCT_EXTERN__BLOCKING_SYNCHRONOUS_METHOD(getSystemVersion)
RCT_EXTERN_METHOD(getBatteryLevel:(RCTPromiseResolveBlock)resolve
reject:(RCTPromiseRejectBlock)reject)
@end
// android/src/main/java/com/deviceinfo/DeviceInfoModule.kt
package com.deviceinfo
import android.os.BatteryManager
import android.content.Context
import com.facebook.react.bridge.*
import com.facebook.react.module.annotations.ReactModule
@ReactModule(name = DeviceInfoModule.NAME)
class DeviceInfoModule(reactContext: ReactApplicationContext) :
ReactContextBaseJavaModule(reactContext) {
companion object { const val NAME = "DeviceInfo" }
override fun getName(): String = NAME
@ReactMethod(isBlockingSynchronousMethod = true)
fun getDeviceId(): String {
return android.provider.Settings.Secure.getString(
reactApplicationContext.contentResolver,
android.provider.Settings.Secure.ANDROID_ID
) ?: "unknown"
}
@ReactMethod(isBlockingSynchronousMethod = true)
fun getSystemVersion(): String = android.os.Build.VERSION.RELEASE
@ReactMethod
fun getBatteryLevel(promise: Promise) {
try {
val batteryManager = reactApplicationContext
.getSystemService(Context.BATTERY_SERVICE) as BatteryManager
promise.resolve(batteryManager.getIntProperty(
BatteryManager.BATTERY_PROPERTY_CAPACITY
).toDouble())
} catch (e: Exception) {
promise.reject("ERROR", e.message, e)
}
}
}
// src/NativeEventEmitter.ts
import { NativeEventEmitter, NativeModules } from 'react-native';
const { BluetoothModule } = NativeModules;
class BluetoothEvents {
private emitter = new NativeEventEmitter(BluetoothModule);
onDeviceFound(callback: (device: BluetoothDevice) => void) {
const sub = this.emitter.addListener('onDeviceFound', callback);
return () => sub.remove();
}
}
export const bluetoothEvents = new BluetoothEvents();
// cpp/NativeCrypto.cpp
#include <jsi/jsi.h>
using namespace facebook::jsi;
void installCrypto(Runtime& runtime) {
auto sha256 = Function::createFromHostFunction(
runtime,
PropNameID::forAscii(runtime, "sha256"),
1,
[](Runtime& runtime, const Value&, const Value* args, size_t) -> Value {
std::string input = args[0].asString(runtime).utf8(runtime);
// SHA256 implementation
return String::createFromUtf8(runtime, hash);
}
);
runtime.global().setProperty(runtime, "nativeSha256", std::move(sha256));
}
Pod::Spec.new do |s|
s.name = "react-native-device-info"
s.version = package["version"]
s.platforms = { :ios => "13.0" }
s.source_files = "ios/**/*.{h,m,mm,swift}"
s.swift_version = "5.0"
install_modules_dependencies(s)
s.dependency "React-Core"
end
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
android {
compileSdkVersion 34
defaultConfig {
minSdkVersion 21
targetSdkVersion 34
}
}
dependencies {
implementation "com.facebook.react:react-native:+"
}
| Issue | Cause | Solution |
|---|---|---|
| "Module not found" | Not linked | Run pod install / sync gradle |
| Crash on sync method | Main thread block | Use async or background thread |
| Turbo Module not loading | Codegen not run | Run npx react-native codegen |
| Type mismatch | Codegen spec mismatch | Regenerate types |
# Verify module registration
adb logcat | grep "ReactNativeJS"
# Check iOS loading
xcrun simctl spawn booted log stream --predicate 'subsystem == "com.facebook.react"'
# Validate Codegen
ls android/build/generated/source/codegen/
Task(subagent_type="react-native:04-react-native-native")
Bonded Skill: react-native-native-modules
Use this agent to verify that a Python Agent SDK application is properly configured, follows SDK best practices and documentation recommendations, and is ready for deployment or testing. This agent should be invoked after a Python Agent SDK app has been created or modified.
Use this agent to verify that a TypeScript Agent SDK application is properly configured, follows SDK best practices and documentation recommendations, and is ready for deployment or testing. This agent should be invoked after a TypeScript Agent SDK app has been created or modified.