Skip to content

feat: add React Native New Architecture support (Turbo Modules + Fabric interop)#48

Draft
mikemilla wants to merge 1 commit intomainfrom
cursor/new-architecture-support-131f
Draft

feat: add React Native New Architecture support (Turbo Modules + Fabric interop)#48
mikemilla wants to merge 1 commit intomainfrom
cursor/new-architecture-support-131f

Conversation

@mikemilla
Copy link
Copy Markdown
Collaborator

Fixes #35

Summary

Adds support for React Native New Architecture (Expo SDK 55 / RN 0.83+) where bridgeless mode is always enabled. The library now works through the Turbo Module and Fabric interop layers while maintaining backward compatibility with older RN versions.

Changes

JavaScript / TypeScript

  • src/Modules.tsx: Native modules are now resolved through TurboModuleRegistry first, falling back to NativeModules for backward compatibility. This ensures modules are discoverable in both bridgeless (New Architecture) and bridge (Old Architecture) modes.

Android

  • ReactNativeModule.kt: Replaced ReactActivity cast with direct Activity reference. In bridgeless mode, currentActivity may not be a ReactActivity, so casting to it would return null and break functionality.

  • CourierClientModule.kt: Fixed a dangerous reactActivity!! force-unwrap in putUserToken(). Now uses reactApplicationContext for CourierDevice.current(), which is always available regardless of architecture mode.

  • CourierSystemModule.kt: Updated all reactActivity references to use the safe activity accessor (returning Activity?). Permission requests and notification checks now work correctly in bridgeless mode.

  • CourierPreferencesViewManager.kt: Fixed unsafe currentActivity as FragmentActivity cast that would crash in bridgeless mode. Now safely falls back to ThemedReactContext when FragmentActivity is unavailable.

  • build.gradle:

    • Changed react-android dependency from hardcoded 0.73.7 to dynamic + so the consuming app's RN version is resolved automatically
    • Added safeExtGet helper so consuming apps can override SDK versions through rootProject.ext
  • gradle.properties: Updated default SDK versions to compileSdk 34, targetSdk 34, minSdk 24, Kotlin 1.9.24 for compatibility with modern RN versions.

iOS

The iOS side already supports New Architecture through the interop layer:

  • install_modules_dependencies in the podspec handles both architecture dependencies
  • RCTEventEmitter and RCTViewManager subclasses work through Fabric/TurboModule interop automatically
  • No code changes needed

Compatibility

RN Version Architecture Status
0.71 - 0.72 Old (bridge) ✅ Supported via NativeModules fallback
0.73 - 0.82 Old or New ✅ Supported via interop layer + TurboModuleRegistry
0.83+ New (always) ✅ Supported via TurboModuleRegistry + interop

Testing

  • All 125 existing Jest tests pass
  • TypeScript type checking passes (no new errors)
  • ESLint passes (no new warnings or errors)
Open in Web Open in Cursor 

…ic interop)

Addresses #35: Support for React Native New Architecture (Expo SDK 55 / RN 0.83+)

Changes:
- Use TurboModuleRegistry with NativeModules fallback for module resolution
  so native modules are discoverable in both bridgeless and bridge modes
- Fix currentActivity null safety: avoid casting to ReactActivity which may
  not exist in bridgeless mode; use Activity directly
- Fix CourierClientModule: use reactApplicationContext for CourierDevice.current()
  instead of force-unwrapping reactActivity
- Fix CourierPreferencesViewManager: safe-cast currentActivity to FragmentActivity
  with fallback to ThemedReactContext
- Update react-android dependency to use dynamic version (+) so the consuming
  app's RN version is resolved automatically
- Update default SDK versions (compileSdk/targetSdk 34, minSdk 24, Kotlin 1.9.24)
- Add safeExtGet helper for SDK version resolution from consuming project

iOS side already supports New Architecture through the interop layer:
- install_modules_dependencies in podspec handles both architectures
- RCTEventEmitter/RCTViewManager work through Fabric/TurboModule interop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Support for React Native New Architecture (Expo SDK 55 / RN 0.83+)

2 participants