react-native-architecture
Use when the user asks about the React Native New Architecture: JSI, Fabric, TurboModules, Codegen, bridgeless mode, the interop layer, Hermes or migrating a…
от j4flmao★ 47 звёзд на GitHub
Установить react-native-architecture в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
React Native Architecture
Purpose
The legacy architecture serialised every JS↔native interaction as asynchronous JSON messages over a bridge. The New Architecture (default since 0.76, the only runtime since 0.82) replaces it with JSI-based direct calls, the Fabric renderer and TurboModules. This skill explains how those pieces work so you can write native modules/components correctly, migrate libraries, and reason about threading and performance.
Agent Protocol
Trigger
"New Architecture", "JSI", "Fabric", "TurboModules", "Codegen", "bridgeless", "bridge", "interop layer", "Hermes", "Yoga", "shadow tree", "synchronous native call", "native component spec".
Input Context
- React Native version; Expo or bare; library vs app
- Native module/component being written or migrated (iOS Swift/Obj-C++, Android Kotlin/C++)
- Symptom (startup time, UI-thread stalls, interop errors)
Output Artifact
Architecture explanation, Codegen specs, native module/component code, migration steps. No file unless requested.
Response Format
RN: {version} Mode: {bridgeless New Architecture}
Piece: {JSI | Fabric | TurboModule | Codegen | Hermes}
Explanation: {mechanism}
Code/spec: {snippet}
Threading: {which thread runs what}
1. Legacy vs New
| Concern | Legacy (bridge) | New Architecture |
|---|---|---|
| JS↔native calls | async batched JSON messages | JSI: C++ host objects/functions callable from JS, sync or async |
| Native modules | all initialised at startup | TurboModules: lazily loaded on first use |
| Rendering | async UIManager over the bridge | Fabric: C++ renderer with immutable shadow trees, supports React concurrent features |
| Type safety | runtime | Codegen from typed specs (TypeScript/Flow) generates C++/ObjC/Java glue |
| Runtime | bridge always present | bridgeless mode (default with the New Architecture) |
2. JSI (JavaScript Interface)
- A C++ API implemented by the JS engine (Hermes by default; JSC available) that lets native code expose
jsi::HostObjects andjsi::Functions to JS and hold references to JS values. - Enables synchronous calls when justified (e.g. reading a small cached value), and zero-copy access to
ArrayBuffers. Synchronous calls block the JS thread — keep them short; long work stays async on native threads. - JSI values must only be touched on the JS thread (use
CallInvokerto schedule back onto it).
3. Fabric Renderer
- React reconciles in JS; Fabric's C++ core builds an immutable shadow tree, runs Yoga (flexbox layout engine in C++), diffs trees and mounts changes on the UI thread.
- Phases: render (JS thread creates shadow nodes) → commit (layout with Yoga, tree promoted) → mount (UI thread applies view mutations).
- Because shadow trees are immutable and shared, rendering can happen on multiple threads and React 18+ features (transitions, Suspense, automatic batching) work; synchronous layout reads (
measureinuseLayoutEffect) are reliable.
4. TurboModules and Codegen
Spec (TypeScript) → Codegen generates native interfaces → you implement them.
// specs/NativeDeviceInfo.ts
import type { TurboModule } from 'react-native';
import { TurboModuleRegistry } from 'react-native';
export interface Spec extends TurboModule {
getBatteryLevel(): Promise<number>;
getModelSync(): string; // synchronous — only for cheap calls
}
export default TurboModuleRegistry.getEnforcing<Spec>('NativeDeviceInfo');
package.jsoncodegenConfigdeclares the spec directory and library name; Codegen runs during the native build (pod install/ Gradle).- Implement on Android in Kotlin/Java (generated
NativeDeviceInfoSpecbase class) and on iOS in Objective-C++/Swift conforming to the generated protocol; C++ TurboModules can be shared across platforms. - Native components follow the same pattern with
codegenNativeComponent<Props>('MyView')specs and Fabric component views. - Simpler alternative for many cases: the Expo Modules API (Swift/Kotlin DSL) which supports the New Architecture without writing Codegen glue.
5. Interop Layer
Legacy native modules and view managers can still run through interop layers in the New Architecture, which eased migration; the React Native team keeps them for the foreseeable future, but new libraries should ship native TurboModule/Fabric implementations. Check library status on reactnative.directory before upgrading to 0.82+.
6. Threads
| Thread | Work |
|---|---|
| JS thread | React render, business logic, JSI calls |
| UI / main thread | mounting native views, gestures, native animations |
| Background (native) | module work you dispatch, image decoding, I/O |
| Reanimated worklets run JS on the UI thread via a separate runtime — that is why UI-thread animations stay smooth while the JS thread is busy. |
7. Hermes
- Bytecode precompiled at build time (faster startup, lower memory than parsing JS at launch); generational GC.
- Profiling: React
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл react-native-architecture?
Use when the user asks about the React Native New Architecture: JSI, Fabric, TurboModules, Codegen, bridgeless mode, the interop layer, Hermes or migrating a library off the old bridge. Explains the runtime and guides native module and component authoring. Not for everyday app work, navigation or OTA updates (use react-native-expertise).
Как установить скилл react-native-architecture?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл react-native-architecture запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
AnthropicToolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
access
AnthropicManage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
configure
AnthropicSet up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
access
AnthropicManage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…