# Behavior traces — react/react-native

> Canonical page: https://codevetter.com/unpack/react-native/behavior-traces

# Behavior traces — react/react-native

Scanned commit b7c0e4986a0242cdd47afd002f3e712e80914c3c (2026-09-22). Generated by codevetter codevetter 1.12.0 on 2026-09-22.

Three flows were traced end-to-end: (A) JS environment init -> app registration -> first render; (B) `react-native start` dev-server boot from the bin shim through Metro.runServer; (C) a TurboModule/native call plus codegen generation. Ordered function calls are named in each claim.
- Startup A1: Metro bundle -> serializer.getModulesRunBeforeMainModule() returns ['react-native/setup-env'] -> setup-env.js calls setUpDefaultReactNativeEnvironment() once (idempotent via `initialized` flag). — [packages/metro-config/src/index.flow.js#L61-66](https://github.com/react/react-native/blob/b7c0e4986a0242cdd47afd002f3e712e80914c3c/packages/metro-config/src/index.flow.js#L61-L66) [packages/react-native/src/setup-env.js#L22](https://github.com/react/react-native/blob/b7c0e4986a0242cdd47afd002f3e712e80914c3c/packages/react-native/src/setup-env.js#L22) [packages/react-native/src/private/setup/setUpDefaultReactNativeEnvironment.js#L11-20](https://github.com/react/react-native/blob/b7c0e4986a0242cdd47afd002f3e712e80914c3c/packages/react-native/src/private/setup/setUpDefaultReactNativeEnvironment.js#L11-L20)
- Startup A2 (ordered): setUpGlobals -> setUpDOM -> setUpPerformance -> polyfillPromise -> setUpTimers -> [__DEV__] setUpReactDevTools -> setUpErrorHandling -> setUpRegeneratorRuntime -> setUpXHR -> setUpAlert -> setUpNavigator -> setUpBatchedBridge -> setUpSegmentFetcher -> [__DEV__] checkNativeVersion, setUpDeveloperTools, LogBox.install() -> require(AppRegistry) -> flag-gated setUpIntersectionObserver/setUpMutationObserver/setUpResizeObserver. — [packages/react-native/src/private/setup/setUpDefaultReactNativeEnvironment.js#L22-62](https://github.com/react/react-native/blob/b7c0e4986a0242cdd47afd002f3e712e80914c3c/packages/react-native/src/private/setup/setUpDefaultReactNativeEnvironment.js#L22-L62)
- Startup A3: AppRegistry module load registers the 'LogBox' surface component, sets global.RN$AppRegistry, and registerCallableModule('AppRegistry', AppRegistry) so native can invoke runApplication over the bridge; user code's registerComponent(appKey, provider) stores runnables[appKey] = (appParameters, displayMode) => renderApplication({...}). — [packages/react-native/Libraries/ReactNative/AppRegistry.js#L11-27](https://github.com/react/react-native/blob/b7c0e4986a0242cdd47afd002f3e712e80914c3c/packages/react-native/Libraries/ReactNative/AppRegistry.js#L11-L27) [packages/react-native/Libraries/ReactNative/AppRegistryImpl.js#L92-120](https://github.com/react/react-native/blob/b7c0e4986a0242cdd47afd002f3e712e80914c3c/packages/react-native/Libraries/ReactNative/AppRegistryImpl.js#L92-L120)
- Startup A4: native calls runApplication -> runnable fires renderApplication -> invariant(rootTag) -> builds <AppContainer rootTag WrapperComponent rootViewStyle initialProps internal_excludeLogBox><RootComponent .../></AppContainer> -> optional DEV debugName wrapper via getCachedComponentWithDebugName -> optional React.unstable_Activity wrapper when useOffscreen -> Renderer.renderElement({element, rootTag: createRootTag(rootTag)}). — [packages/react-native/Libraries/ReactNative/renderApplication.js#L39-92](https://github.com/react/react-native/blob/b7c0e4986a0242cdd47afd002f3e712e80914c3c/packages/react-native/Libraries/ReactNative/renderApplication.js#L39-L92) [packages/react-native/Libraries/ReactNative/AppRegistryImpl.js#L97-115](https://github.com/react/react-native/blob/b7c0e4986a0242cdd47afd002f3e712e80914c3c/packages/react-native/Libraries/ReactNative/AppRegistryImpl.js#L97-L115)
- Startup A5 (platform): Android ReactActivityDelegate resolves ReactHost (bridgeless) -> ReactHostImpl lazily creates the ReactInstance guarded by Bolts Tasks; the deprecated path builds ReactInstanceManager via ReactNativeHost.getBaseReactInstanceManagerBuilder().setJSMainModulePath(...).addPackage(each getPackages()).build(). iOS: RCTReactNativeFactory.initWithDelegate:releaseLevel: -> _setUpFeatureFlags -> applyDefaultColorSpace -> createRCTRootViewFactory -> startReactNativeWithModuleName:inWindow:. — [packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactActivityDelegate.java#L87-100](https://github.com/react/react-native/blob/b7c0e4986a0242cdd47afd002f3e712e80914c3c/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactActivityDelegate.java#L87-L100) [packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactNativeHost.kt#L79-121](https://github.com/react/react-native/blob/b7c0e4986a0242cdd47afd002f3e712e80914c3c/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactNativeHost.kt#L79-L121) [packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactHostImpl.kt#L86-120](https://github.com/react/react-native/blob/b7c0e4986a0242cdd47afd002f3e712e80914c3c/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactHostImpl.kt#L86-L120) [packages/react-native/Libraries/AppDelegate/RCTReactNativeFactory.mm#L76-100](https://github.com/react/react-native/blob/b7c0e4986a0242cdd47afd002f3e712e80914c3c/packages/react-native/Libraries/AppDelegate/RCTReactNativeFactory.mm#L76-L100)
- Dev server B1: `react-native` bin -> cli.js -> findCommunityCli() resolves '@react-native-community/cli' from process.cwd() (supports pnpm-style isolated node_modules) -> cli.run('react-native'); when required as a library, a missing community CLI is silently tolerated. — [packages/react-native/cli.js#L24-32](https://github.com/react/react-native/blob/b7c0e4986a0242cdd47afd002f3e712e80914c3c/packages/react-native/cli.js#L24-L32) [packages/react-native/cli.js#L67-91](https://github.com/react/react-native/blob/b7c0e4986a0242cdd47afd002f3e712e80914c3c/packages/react-native/cli.js#L67-L91)
- Dev server B2: community CLI loads react-native.config.js which pushes bundleCommand, startCommand, codegenCommand, spmCommand from @react-native/community-cli-plugin and dynamically resolves @react-native-community/cli-platform-{android,ios} for platform project/dependency config. — [packages/react-native/react-native.config.js#L34-70](https://github.com/react/react-native/blob/b7c0e4986a0242cdd47afd002f3e712e80914c3c/packages/react-native/react-native.config.js#L34-L70) [packages/react-native/react-native.config.js#L72-100](https://github.com/react/react-native/blob/b7c0e4986a0242cdd47afd002f3e712e80914c3c/packages/react-native/react-native.config.js#L72-L100)
- Dev server B3 (ordered inside runDevServer): loadMetroConfig(cliConfig, {...flags}) -> isDevServerRunning(devServerUrl, projectRoot) returning 'matched_server_running'|'port_taken' -> build TerminalReporter (or --custom-log-reporter-path) -> loadCommunityMiddleware().createCommunityMiddleware({host, port, watchFolders}) -> createDevMiddleware({serverBaseUrl, logger}) -> Metro.runServer(metroConfig, {host, secure, secureCert, secureKey, unstable_extraMiddleware: [communityMiddleware, middleware], websocketEndpoints: merged}) -> eventsSocketEndpoint.reportEvent wired into the reporter -> version.logIfUpdateAvailable. — [packages/community-cli-plugin/src/dev-server/runDevServer.js#L46-166](https://github.com/react/react-native/blob/b7c0e4986a0242cdd47afd002f3e712e80914c3c/packages/community-cli-plugin/src/dev-server/runDevServer.js#L46-L166) [packages/dev-middleware/src/createDevMiddleware.js#L87-146](https://github.com/react/react-native/blob/b7c0e4986a0242cdd47afd002f3e712e80914c3c/packages/dev-middleware/src/createDevMiddleware.js#L87-L146)
- Dev server B4 (key handlers): when interactive, 'initialize_done' triggers attachKeyHandlers({devServerUrl, messageSocket, reporter}) so pressing keys (e.g. open debugger via OpenDebuggerKeyboardHandler) talks to the dev middleware over the message socket. — [packages/community-cli-plugin/src/dev-server/runDevServer.js#L134-146](https://github.com/react/react-native/blob/b7c0e4986a0242cdd47afd002f3e712e80914c3c/packages/community-cli-plugin/src/dev-server/runDevServer.js#L134-L146) [packages/community-cli-plugin/src/dev-server/attachKeyHandlers.js](https://github.com/react/react-native/blob/b7c0e4986a0242cdd47afd002f3e712e80914c3c/packages/community-cli-plugin/src/dev-server/attachKeyHandlers.js) [packages/community-cli-plugin/src/dev-server/OpenDebuggerKeyboardHandler.js](https://github.com/react/react-native/blob/b7c0e4986a0242cdd47afd002f3e712e80914c3c/packages/community-cli-plugin/src/dev-server/OpenDebuggerKeyboardHandler.js)
- Native call C1: a spec module like NativeDevSettings re-exports the typed interface from src/private/specs_DEPRECATED/modules; callers do TurboModuleRegistry.getEnforcing('DevSettings') -> global.__turboModuleProxy('DevSettings') (JSI-installed proxy) -> fallback NativeModules['DevSettings'] -> invariant throw 'Verify that a module by this name is registered in the native binary.' — [packages/react-native/Libraries/NativeModules/specs/NativeDevSettings.js](https://github.com/react/react-native/blob/b7c0e4986a0242cdd47afd002f3e712e80914c3c/packages/react-native/Libraries/NativeModules/specs/NativeDevSettings.js) [packages/react-native/Libraries/TurboModule/TurboModuleRegistry.js#L19-47](https://github.com/react/react-native/blob/b7c0e4986a0242cdd47afd002f3e712e80914c3c/packages/react-native/Libraries/TurboModule/TurboModuleRegistry.js#L19-L47) [packages/react-native/src/private/specs_DEPRECATED/modules](https://github.com/react/react-native/blob/b7c0e4986a0242cdd47afd002f3e712e80914c3c/packages/react-native/src/private/specs_DEPRECATED/modules)
- Codegen C2 (ordered): `react-native codegen` -> require.resolve('react-native/scripts/codegen/generate-artifacts-executor/index') -> .execute(path, platform, outputPath, source) -> parsers produce schemas (combine-js-to-schema-cli merges per-library schemas) -> RNCodegen.generate validates each schema via SchemaValidator.validate then fans out to the requested LIBRARY_GENERATORS -> checkOrWriteFiles writes output dirs or diffs in test mode. — [packages/community-cli-plugin/src/commands/codegen.js#L44-60](https://github.com/react/react-native/blob/b7c0e4986a0242cdd47afd002f3e712e80914c3c/packages/community-cli-plugin/src/commands/codegen.js#L44-L60) [packages/react-native/scripts/codegen/generate-artifacts-executor/index.js](https://github.com/react/react-native/blob/b7c0e4986a0242cdd47afd002f3e712e80914c3c/packages/react-native/scripts/codegen/generate-artifacts-executor/index.js) [packages/react-native-codegen/src/cli/combine/combine-js-to-schema-cli.js](https://github.com/react/react-native/blob/b7c0e4986a0242cdd47afd002f3e712e80914c3c/packages/react-native-codegen/src/cli/combine/combine-js-to-schema-cli.js) [packages/react-native-codegen/src/generators/RNCodegen.js#L241-308](https://github.com/react/react-native/blob/b7c0e4986a0242cdd47afd002f3e712e80914c3c/packages/react-native-codegen/src/generators/RNCodegen.js#L241-L308)
- Bundle flow (release): `react-native bundle` -> buildBundle (unstable_buildBundleWithConfig exported for embedders) -> Metro bundle build -> saveAssets writes resolved asset files per platform (getAssetDestPathAndroid / getAssetDestPathIOS / assetCatalogIOS / filterPlatformAssetScales); Metro's transformer.assetRegistryPath is 'react-native/asset-registry' so asset requires become registry calls. — [packages/community-cli-plugin/src/commands/bundle/index.js#L26-60](https://github.com/react/react-native/blob/b7c0e4986a0242cdd47afd002f3e712e80914c3c/packages/community-cli-plugin/src/commands/bundle/index.js#L26-L60) [packages/community-cli-plugin/src/commands/bundle/buildBundle.js](https://github.com/react/react-native/blob/b7c0e4986a0242cdd47afd002f3e712e80914c3c/packages/community-cli-plugin/src/commands/bundle/buildBundle.js) [packages/community-cli-plugin/src/commands/bundle/saveAssets.js](https://github.com/react/react-native/blob/b7c0e4986a0242cdd47afd002f3e712e80914c3c/packages/community-cli-plugin/src/commands/bundle/saveAssets.js) [packages/community-cli-plugin/src/commands/bundle/assetCatalogIOS.js](https://github.com/react/react-native/blob/b7c0e4986a0242cdd47afd002f3e712e80914c3c/packages/community-cli-plugin/src/commands/bundle/assetCatalogIOS.js) [packages/metro-config/src/index.flow.js#L85-89](https://github.com/react/react-native/blob/b7c0e4986a0242cdd47afd002f3e712e80914c3c/packages/metro-config/src/index.flow.js#L85-L89)

Every claim links to its cited files at the pinned commit. Citations identify source evidence; they do not establish runtime correctness. Independent CodeVetter scan — not reviewed by upstream maintainers.

## Public product links

- [CodeVetter](https://codevetter.com/)
- [Download](https://codevetter.com/download)
- [Documentation](https://codevetter.com/docs/)
- [Source](https://github.com/Codevetter/codevetter)
