React Native Compatibility (@hozo/rn-compat)
@hozo/rn-compat provides compatibility components and non-JSX APIs for migrating existing React Native applications to Hozo without keeping react-native-web for the supported surface.
import { AccessibilityInfo, ActivityIndicator, Animated, Dimensions, Keyboard, Modal, PanResponder, Platform, StyleSheet, TouchableOpacity, TouchableWithoutFeedback, useColorScheme, useWindowDimensions,} from '@hozo/rn-compat'How it works across platforms
Section titled “How it works across platforms”- On React Native: the package’s
react-nativeexport condition resolves directly to React Native’s own implementations. ImportingPlatformorStyleSheetfrom@hozo/rn-compaton iOS or Android hands back React Native’s exact object. - On the Web:
@hozo/rn-compatprovides focused, accessible DOM implementations without pulling inreact-native-web.
Canonical UI primitives (View, Text, Pressable, Image, TextInput, ScrollView, FlatList, RefreshControl) live in @hozo/primitives (and @hozo/core), not in @hozo/rn-compat.
Supported surface
Section titled “Supported surface”- Components:
Modal,ActivityIndicator,TouchableOpacity, andTouchableWithoutFeedback(each also recognized and lowered by the Hozo compiler; see the Primitives reference). - Narrow animation adapter:
Animated.View(for style-driven view wrappers; fullAnimatedgraphs, drivers, and interpolation remain outside this package). - Platform & layout APIs:
Platform,Dimensions,Keyboard,AccessibilityInfo,StyleSheet,PanResponder,useColorScheme, anduseWindowDimensions.
Automatic import rewriting
Section titled “Automatic import rewriting”You can import from @hozo/rn-compat directly, or let Hozo rewrite existing react-native imports during migration:
- At build time (Web only): when
unloweredReactNativeJsxis set to'warn'or'error'in your bundler configuration, the Web compiler automatically rewrites supported API imports fromreact-nativeto@hozo/rn-compat(and warns withRN_COMPAT_NOT_INSTALLEDif the package is not inpackage.json). - In source (
@hozo/migration-audit --fix): runningnpx @hozo/migration-audit . --fix --writewrites those exact import moves into your shared source files so the dependency boundary is explicit in Git. See the Migration Audit guide.