Files
2nd/10_Wiki/Topics/Domain_Programming/Frontend/TurboModules.md
T
Antigravity Agent c24165b8bc refactor(topics): 멀티 에이전트용 지식 재편 — _Common(공통 기본기) + Domain_* 구조
에이전트 8종(대화형/프로그래머 C·S/디자이너/설계자/기획자/QA/PD/PM)에게
[공통 기본 능력 + 롤별 Specialty] 2층으로 지식을 주입하기 위한 재분류.
문서 내용·포맷은 무수정, 폴더 이동만 (6,372개 문서 수 보존 확인).

- Topic_Programming → Domain_Programming (내부 구조 보존)
- Topic_Graphic → Domain_Design
- Topic_Business → Domain_Product
- Topic_General → Domain_General
- _Common 신설: Math(구 Topic_Math_Specialty), Reasoning(구 General/From_Thinking & Reasoning),
  Reasoning_Creativity(구 General/From_창의성), Communication(Poetic_Blog_Writing + From_writing)
- 타 도메인의 From_* 폴더는 유지 (출처 표기일 뿐, 이미 도메인에 맞게 분류된 문서)
- 빈 폴더 정리 (memory/procedures)
- 에이전트→폴더 매핑은 workspace의 .astra/agent-knowledge-map.json (9개 에이전트)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-11 11:05:56 +09:00

5.0 KiB

id, title, category, status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, verification_status, tags, raw_sources, last_reinforced, github_commit, tech_stack
id title category status canonical_id aliases duplicate_of source_trust_level confidence_score verification_status tags raw_sources last_reinforced github_commit tech_stack
wiki-2026-0508-turbomodules TurboModules 10_Wiki/Topics verified self
React Native TurboModules
RN New Architecture Modules
none A 0.9 applied
react-native
jsi
native-modules
new-architecture
2026-05-10 pending
language framework
typescript react-native

TurboModules

매 한 줄

"매 JSI-direct 의 type-safe native module". TurboModules 의 React Native 의 New Architecture 의 native-side API 의 JS 의 expose, 매 legacy bridge (JSON serialize) 의 X 의 JSI 의 direct C++ call, 매 codegen 의 type safety. 매 2026: RN 0.76+ 의 New Architecture 의 default — TurboModules + Fabric 의 baseline.

매 핵심

매 legacy NativeModule 의 차이

  • Legacy: async-only, JSON serialize, 매 batched message queue, runtime type check.
  • TurboModule: sync 또는 async, JSI direct call, lazy load, codegen-typed (Flow/TS spec).
  • Perf: 매 startup 의 lazy load 의 win, 매 call 의 serialize overhead 의 zero.

매 codegen flow

  1. JS spec file (Native<Name>.ts) 의 author — 매 TurboModule interface.
  2. react-native codegen 의 ObjC++ / Java header 의 generate.
  3. Native impl 의 generated header 의 conform.
  4. JS 의 TurboModuleRegistry.getEnforcing<Spec>('Name') 의 access.

매 응용

  1. Custom native sensor / Bluetooth API.
  2. Heavy native compute (image filter, ML preprocess) 의 JSI sync 의 expose.
  3. Vendor SDK wrapping (payment, analytics).
  4. Library author 의 RN 0.76+ 의 publish.

💻 패턴

Spec file (TS)

// specs/NativeMathLib.ts
import type { TurboModule } from 'react-native';
import { TurboModuleRegistry } from 'react-native';

export interface Spec extends TurboModule {
  add(a: number, b: number): number;
  multiplyAsync(a: number, b: number): Promise<number>;
  getDeviceInfo(): { model: string; os: string };
}

export default TurboModuleRegistry.getEnforcing<Spec>('MathLib');

Codegen config (package.json)

{
  "name": "react-native-mathlib",
  "codegenConfig": {
    "name": "RNMathLibSpec",
    "type": "modules",
    "jsSrcsDir": "specs",
    "android": { "javaPackageName": "com.mathlib" }
  }
}

iOS impl (ObjC++)

// MathLib.mm
#import "MathLib.h"
#import <RNMathLibSpec/RNMathLibSpec.h>

@implementation MathLib
RCT_EXPORT_MODULE()

- (NSNumber *)add:(double)a b:(double)b {
  return @(a + b);
}

- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
    (const facebook::react::ObjCTurboModule::InitParams &)params {
  return std::make_shared<facebook::react::NativeMathLibSpecJSI>(params);
}
@end

Android impl (Kotlin)

class MathLibModule(reactContext: ReactApplicationContext) :
    NativeMathLibSpec(reactContext) {

  override fun getName() = "MathLib"

  override fun add(a: Double, b: Double): Double = a + b

  override fun multiplyAsync(a: Double, b: Double, promise: Promise) {
    promise.resolve(a * b)
  }
}

JS consumption

import MathLib from './specs/NativeMathLib';

const sum = MathLib.add(2, 3); // 매 sync — 매 JSI direct
const product = await MathLib.multiplyAsync(4, 5);

Enable New Architecture

# 매 RN 0.76+ default — 매 0.74 의 opt-in
# iOS:
RCT_NEW_ARCH_ENABLED=1 pod install
# Android: gradle.properties
newArchEnabled=true

Lazy access guard

const MathLib = TurboModuleRegistry.get<Spec>('MathLib');
if (MathLib == null) {
  throw new Error('MathLib not linked');
}

매 결정 기준

상황 Approach
신규 RN library (2026) TurboModule + codegen
Legacy 0.68 below 의 maintain NativeModule (deprecated path)
Sync native call 의 require TurboModule (legacy 의 X)
UI component (not API) Fabric component (sibling 의 New Arch)
Cross-platform native TurboModule + shared C++ via JSI

기본값: 매 RN 0.76+ 의 모든 native module 의 TurboModule.

🔗 Graph

🤖 LLM 활용

언제: 매 RN 0.76+ 의 native module 의 author 또는 migrate. 언제 X: 매 expo-managed app — 매 prebuild 또는 config plugin 의 prefer.

안티패턴

  • Spec file 의 codegen 의 skip 의 manual header: 매 type drift — 매 always codegen.
  • Sync TurboModule 의 long-running task: 매 JS thread block — 매 async 의 use.
  • Bridge module 의 New Arch 의 mix: 매 deprecation warning + perf loss.
  • getEnforcing 없 의 unchecked access: 매 null reference 의 silent fail.
  • C++ TurboModule 의 type 의 manual marshal: 매 codegen 의 auto-handle 의 ignore.

🧪 검증 / 중복

  • Verified (RN 0.76+ docs, reactnative.dev/docs/the-new-architecture).
  • 신뢰도 A.

🕓 Changelog

날짜 변경
2026-05-08 Phase 1
2026-05-10 Manual cleanup — codegen, JSI direct, iOS/Android impl