You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Nitro Modules v1: research breaking changes and React Native support #1100
Part of the Nitro Modules v1 + RN-free RNQC milestone (context: #1099).
Find out what moving RNQC from Nitro Modules 0.35 to Nitro Modules v1 (margelo/nitro branch v1, currently 1.0.0-alpha.nightly.*) breaks: nitro.json keys, spec syntax, how hybrid objects are created (constructors replace createHybridObject), C++ headers and base classes, Promise/callback/ArrayBuffer types, generated output layout, autolinking, SwiftPM vs CocoaPods, and how React Native is supported.
Done when: there is a written list of breaking changes, each marked mechanical or needs design, and the decisions below are settled.
Decisions to settle: package names, the core/React Native boundary, whether #1099 seeds the core package or is closed, whether RNQC's React Native integration moves to Nitro Modules v1 or stays on Nitro Modules 0.x until v1 is stable, and how next is released.
Versions used below: Nitro Modules (react-native-nitro-modules, nitro-core, nitrogen) is currently 0.35 in RNQC, and the new major is Nitro Modules v1. RNQC (react-native-quick-crypto) is currently 1.1.10, and moving it to Nitro Modules v1 would make RNQC 2.0. React Native (RN) versions are given as RN 0.81, RN 0.88.
Source: margelo/nitro branch v1 at 43e09c1, the same build as the Nitro Modules npm 1.0.0-alpha.nightly.138.
Requirements and compatibility
Nitro Modules v1 needs RN 0.88 or newer, New Architecture only (peer dependency react-native >=0.88.0). RNQC's example app is on RN 0.81.1.
Apple: iOS 16+, Swift 6.4 and Swift Package Manager only. CocoaPods projects are told to run npx react-native spm add --deintegrate; feat: support CocoaPods alongside SwiftPM nitro#2054, which adds CocoaPods back, is open and was last updated Nov 9.
No interop between Nitro Modules 0.x and v1 in either direction.createHybridObject is gone and registration now goes through getHybridClass and HybridClassRegistry. An app has to be on Nitro Modules v1 to use an RNQC built on it, so that RNQC release is a semver major (RNQC 2.0).
Stability: Nitro Modules v1 is published only as alpha-nightly, with no changelog or timeline.
Nitro Modules 0.35 → v1 breaking changes for RNQC
Area
Change
Effort
nitro.json
ios.iosModuleName becomes apple.moduleName; android.androidNamespace and android.androidCxxLibName become namespace and cxxLibName; environment is new; the autolinking block is now an error.
Mechanical
Specs (28)
interface X extends HybridObject<…> becomes @Apple/@Android decorators on export declare class X extends HybridObject, plus export * from '#nitro/X' and a package.jsonimports map. Overloads, rest parameters and generics are unsupported.
Mechanical
Object creation (65 call sites)
createHybridObject is replaced by constructors and statics. Upstream AGENTS.md says stateless APIs should be statics.
Needs design
C++ base class
HybridObject(TAG) becomes HybridObject() (37 sites); registration moves to HybridClass.
Mechanical
Raw JSI methods
The three loadHybridMethods() overrides (HybridUtils.hpp, HybridRsaCipher.hpp, HybridKeyObjectHandle.hpp) have to be re-expressed through registerRawHybridMethod on a HybridClass.
Small design
Types
ArrayBuffer becomes a value type (const ArrayBuffer& in, ArrayBuffer out), about 440 sites. Promise<T> is returned by value, about 50 sites. Callbacks become Callback<void(T)>. optional, variant and hybrid references are unchanged.
Mechanical, large
Generated layout
Headers are module-prefixed (<QuickCrypto/HybridXSpec.hpp>), generated JS is shared/javascript/*.cjs, and ios/ becomes apple/.
Mechanical
Apple build
Moves to Package.swift with addNitrogenTargets; the podspec becomes metadata only. The OpenSSL download moves to a .binaryTarget, as in #1099. libsodium's ./configure build has no Swift package equivalent, so it needs a prebuilt xcframework or has to go.
Rewrite
Android build
registerAllNatives() and <Lib>OnLoad.initializeNative() replace initialize(vm). CMakeLists.txt stays ours, so the opensslstatic prefab and --exclude-libs carry over.
Mechanical
Because the ArrayBuffer and Promise types differ, the C++ can't be shared between an RNQC build on Nitro Modules 0.x and one on Nitro Modules v1 without a compatibility layer.
Do we need two packages?
Nitro Modules v1 does not require it. The "Inside a nitro module library" section of the Nitro Modules v1 react-native-nitro-modules README says a library should declare nitro-core and react-native-nitro-modules as optional peer dependencies, so one package can serve both a React Native app and a non-React Native host.
Resolved by test (results): generate once with "environment": "bare" and add a thin React Native layer. The two environments' nitrogen output differs only in the generated JS and the Android CMake; the Apple output is identical. The same package ran in an RN 0.88 app on iOS and Android and in a bare Hermes host on iOS. #1101 is now "make the single package work without React Native" rather than a split.
Only src/utils/conversion.ts imports react-native today.
Decisions
Final outcomes: see the decisions comment. The table below is the original proposal.
#
Decision
Recommendation
1
Move RNQC's React Native integration to Nitro Modules v1, or keep it on Nitro Modules 0.x
Everything moves to Nitro Modules v1 on next (RNQC 2.0); main stays on Nitro Modules 0.x (RNQC 1.x), with crypto fixes backported by hand until the merge.
2
One package or a split
Settled by test: one package (results). Split only for a product reason Nitro Modules doesn't impose, such as a different release cadence.
3
Name
RNQC 2.0 is a major, so this is the cheapest moment to rename. Bare quick-crypto and nitro-crypto are taken on npm; @margelo/quick-crypto is free, once Margelo control of the @margelo npm scope is confirmed. If we rename, keep react-native-quick-crypto publishing as a deprecated re-export for one or two majors. If apps without React Native aren't a real goal, keep the current name.
4
Internal API
Statics for stateless modules (Random, Utils, Pbkdf2, …) and constructors for stateful ones (new Hash(algo)). The public crypto.* and subtle.* API doesn't change.
5
libsodium on Apple
A prebuilt xcframework release asset, like OpenSSL, or audit what still uses libsodium and drop it.
Close it once RNQC 2.0 (on Nitro Modules v1) lands. Reuse its separate Android shared library with hidden symbols and its Swift package OpenSSL binary target in #1103, with credit.
7
Release
Publish 2.0.0-next.N under the npm next tag, pinned to an exact Nitro Modules v1 nightly. Merge to main once Nitro Modules v1 is stable and either CocoaPods support lands or we decide to require Swift packages.
Not verified
Whether a bare-generated .cjs runs unchanged under React Native. It does, provided react-native-nitro-modules is imported first (results).
Whether Swift package cxxSources can point outside the package root in an npm install. No longer needed with one package.
changed the title [-]Nitro v1: research breaking changes and RN support[/-][+]Nitro Modules v1: research breaking changes and React Native support[/+]on Nov 28, 2026
Yes, with changes. A package generated with "environment": "bare" in nitro.json, plus a thin React Native layer, runs in both an RN 0.88 app and a bare Hermes host with no React Native. A separate core package isn't needed for Nitro Modules v1's sake. Whether to have one anyway is a product decision.
Setup: Nitro Modules v1 at margelo/nitro@43e09c1 (npm 1.0.0-alpha.nightly.138), with the #1099quick-crypto-nitro package as the test subject. Check: createHash('sha256').update('abc').digest('hex'), expected ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad.
Host
iOS (iPhone 18 Pro sim, iOS 27.2)
Android (Pixel 8 Pro AVD, arm64)
RN 0.88 (Nitro Modules v1 example app)
✅ correct digest, with the changes below
✅ correct digest, with the changes below
Bare Hermes (Nitro Modules v1 standalone test runner)
Nitrogen's output differs between the two environments in only two files: shared/javascript/Hash.cjs (it imports nitro-core or react-native-nitro-modules) and android/QuickCryptoNitro+autolinking.cmake. The Apple output is identical. The react-native output does not work in the bare host: the bundle pulls in react-native/index.js, and the CMake needs ReactAndroid. So we generate once as bare and add a React Native layer.
What the React Native layer needs
JS entry point:exports["."]["react-native"] points to an RN entry that imports react-native-nitro-modules first, then re-exports the shared entry. Without that order you get Nitro Modules must be installed before importing nitro-core. Both nitro-core and react-native-nitro-modules become optional peer dependencies.
Android library:android/ becomes a real RN library: manifest, namespace, a cpp-adapter.cpp that calls registerAllNatives() from JNI_OnLoad, and a Kotlin package class. A dependencies-only build.gradle breaks react-native config for the whole app.
Android CMake shim: a small nitro-core-config.cmake defines nitro-core::NitroModules on top of react-native-nitro-modules::NitroModules, ReactAndroid::jsi, ReactAndroid::reactnative and the Folly defines, and CMakeLists.txt sets nitro-core_DIR to it. CMAKE_PREFIX_PATH doesn't work, because the Android toolchain re-roots it.
iOS autolinking: a stub *.podspec, react-native.config.js and swiftpmConfig in package.json. Drop "type": "module", which made react-native.config.js unreadable.
Package.swift:
Compile the generated QuickCryptoNitroAutolinking.mm. Without it you get HybridClass "quickcrypto.Hash" is not registered.
Pick the Nitro Modules package at build time: ../NitroModules under RN, ../nitro-core for bare. Add the DEBUG/NDEBUG defines.
Not tested
Bare Android.
The bare branch of the new Package.swift. In the test, bare iOS was built through the Nitro repo's root Package.swift.
Whether compiling the autolinking .mm and also calling registerHybridClasses() by hand in a bare host registers twice.
Release builds, Android ABIs other than arm64-v8a, and Expo.
Effect on the plan
Decision 2 resolves to one package, unless there's a reason Nitro Modules doesn't impose.
Everything moves to Nitro Modules v1 on next as RNQC 2.0. main stays on Nitro Modules 0.x (RNQC 1.x), and crypto fixes are backported to next by hand until the merge.
Audit what still uses libsodium. If it's still needed, ship a prebuilt xcframework release asset with a pinned checksum, like OpenSSL; otherwise drop it.
Close it now. Its separate Android shared library with hidden symbols, its Swift package OpenSSL binary target and its shared HashContext.hpp are reused in #1101 and #1103.
2.0.0-next.N under the npm next tag, pinned to an exact Nitro Modules v1 nightly. Merge to main once Nitro Modules v1 is stable and either CocoaPods support lands (margelo/nitro#2054) or we decide to require Swift packages.
Activity
boorad commentedon Nov 28, 2026
Nitro Modules v1 research findings
Versions used below: Nitro Modules (
react-native-nitro-modules,nitro-core,nitrogen) is currently 0.35 in RNQC, and the new major is Nitro Modules v1. RNQC (react-native-quick-crypto) is currently 1.1.10, and moving it to Nitro Modules v1 would make RNQC 2.0. React Native (RN) versions are given asRN 0.81,RN 0.88.Source:
margelo/nitrobranchv1at43e09c1, the same build as the Nitro Modules npm1.0.0-alpha.nightly.138.Requirements and compatibility
react-native >=0.88.0). RNQC's example app is on RN 0.81.1.npx react-native spm add --deintegrate; feat: support CocoaPods alongside SwiftPM nitro#2054, which adds CocoaPods back, is open and was last updated Nov 9.createHybridObjectis gone and registration now goes throughgetHybridClassandHybridClassRegistry. An app has to be on Nitro Modules v1 to use an RNQC built on it, so that RNQC release is a semver major (RNQC 2.0).alpha-nightly, with no changelog or timeline.Nitro Modules 0.35 → v1 breaking changes for RNQC
nitro.jsonios.iosModuleNamebecomesapple.moduleName;android.androidNamespaceandandroid.androidCxxLibNamebecomenamespaceandcxxLibName;environmentis new; theautolinkingblock is now an error.interface X extends HybridObject<…>becomes@Apple/@Androiddecorators onexport declare class X extends HybridObject, plusexport * from '#nitro/X'and apackage.jsonimportsmap. Overloads, rest parameters and generics are unsupported.createHybridObjectis replaced by constructors and statics. UpstreamAGENTS.mdsays stateless APIs should be statics.HybridObject(TAG)becomesHybridObject()(37 sites); registration moves toHybridClass.loadHybridMethods()overrides (HybridUtils.hpp,HybridRsaCipher.hpp,HybridKeyObjectHandle.hpp) have to be re-expressed throughregisterRawHybridMethodon aHybridClass.ArrayBufferbecomes a value type (const ArrayBuffer&in,ArrayBufferout), about 440 sites.Promise<T>is returned by value, about 50 sites. Callbacks becomeCallback<void(T)>.optional,variantand hybrid references are unchanged.<QuickCrypto/HybridXSpec.hpp>), generated JS isshared/javascript/*.cjs, andios/becomesapple/.Package.swiftwithaddNitrogenTargets; the podspec becomes metadata only. The OpenSSL download moves to a.binaryTarget, as in #1099. libsodium's./configurebuild has no Swift package equivalent, so it needs a prebuilt xcframework or has to go.registerAllNatives()and<Lib>OnLoad.initializeNative()replaceinitialize(vm).CMakeLists.txtstays ours, so theopensslstaticprefab and--exclude-libscarry over.Because the
ArrayBufferandPromisetypes differ, the C++ can't be shared between an RNQC build on Nitro Modules 0.x and one on Nitro Modules v1 without a compatibility layer.Do we need two packages?
Nitro Modules v1 does not require it. The "Inside a nitro module library" section of the Nitro Modules v1
react-native-nitro-modulesREADME says a library should declarenitro-coreandreact-native-nitro-modulesas optional peer dependencies, so one package can serve both a React Native app and a non-React Native host.Resolved by test (results): generate once with
"environment": "bare"and add a thin React Native layer. The two environments' nitrogen output differs only in the generated JS and the Android CMake; the Apple output is identical. The same package ran in an RN 0.88 app on iOS and Android and in a bare Hermes host on iOS. #1101 is now "make the single package work without React Native" rather than a split.Only
src/utils/conversion.tsimportsreact-nativetoday.Decisions
next(RNQC 2.0);mainstays on Nitro Modules 0.x (RNQC 1.x), with crypto fixes backported by hand until the merge.quick-cryptoandnitro-cryptoare taken on npm;@margelo/quick-cryptois free, once Margelo control of the@margelonpm scope is confirmed. If we rename, keepreact-native-quick-cryptopublishing as a deprecated re-export for one or two majors. If apps without React Native aren't a real goal, keep the current name.new Hash(algo)). The publiccrypto.*andsubtle.*API doesn't change.2.0.0-next.Nunder the npmnexttag, pinned to an exact Nitro Modules v1 nightly. Merge tomainonce Nitro Modules v1 is stable and either CocoaPods support lands or we decide to require Swift packages.Not verified
Whether aIt does, providedbare-generated.cjsruns unchanged under React Native.react-native-nitro-modulesis imported first (results).cxxSourcescan point outside the package root in an npm install. No longer needed with one package.Example app upgrade to RN 0.88: #1106
[-]Nitro v1: research breaking changes and RN support[/-][+]Nitro Modules v1: research breaking changes and React Native support[/+]boorad commentedon Nov 28, 2026
@hannojg decision
2 &3 above 🙏boorad commentedon Nov 28, 2026
Test result: one package can serve both hosts
Yes, with changes. A package generated with
"environment": "bare"innitro.json, plus a thin React Native layer, runs in both an RN 0.88 app and a bare Hermes host with no React Native. A separate core package isn't needed for Nitro Modules v1's sake. Whether to have one anyway is a product decision.Setup: Nitro Modules v1 at
margelo/nitro@43e09c1(npm1.0.0-alpha.nightly.138), with the #1099quick-crypto-nitropackage as the test subject. Check:createHash('sha256').update('abc').digest('hex'), expectedba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad.quick-crypto.test.tspassed; 26/26 Swift testsWhy
bareand notreact-nativeNitrogen's output differs between the two environments in only two files:
shared/javascript/Hash.cjs(it importsnitro-coreorreact-native-nitro-modules) andandroid/QuickCryptoNitro+autolinking.cmake. The Apple output is identical. Thereact-nativeoutput does not work in the bare host: the bundle pulls inreact-native/index.js, and the CMake needsReactAndroid. So we generate once asbareand add a React Native layer.What the React Native layer needs
exports["."]["react-native"]points to an RN entry that importsreact-native-nitro-modulesfirst, then re-exports the shared entry. Without that order you getNitro Modules must be installed before importing nitro-core.Bothnitro-coreandreact-native-nitro-modulesbecome optional peer dependencies.android/becomes a real RN library: manifest, namespace, acpp-adapter.cppthat callsregisterAllNatives()fromJNI_OnLoad, and a Kotlin package class. A dependencies-onlybuild.gradlebreaksreact-native configfor the whole app.nitro-core-config.cmakedefinesnitro-core::NitroModuleson top ofreact-native-nitro-modules::NitroModules,ReactAndroid::jsi,ReactAndroid::reactnativeand the Folly defines, andCMakeLists.txtsetsnitro-core_DIRto it.CMAKE_PREFIX_PATHdoesn't work, because the Android toolchain re-roots it.*.podspec,react-native.config.jsandswiftpmConfiginpackage.json. Drop"type": "module", which madereact-native.config.jsunreadable.Package.swift:QuickCryptoNitroAutolinking.mm. Without it you getHybridClass "quickcrypto.Hash" is not registered.../NitroModulesunder RN,../nitro-corefor bare. Add theDEBUG/NDEBUGdefines.Not tested
Package.swift. In the test, bare iOS was built through the Nitro repo's rootPackage.swift..mmand also callingregisterHybridClasses()by hand in a bare host registers twice.Effect on the plan
boorad commentedon Nov 28, 2026
Decisions (final)
Decided by @boorad as maintainer.
nextas RNQC 2.0.mainstays on Nitro Modules 0.x (RNQC 1.x), and crypto fixes are backported tonextby hand until the merge.bare, plus a thin React Native layer (test results).react-native-quick-crypto.createHybridObject. The publiccrypto.*andsubtle.*API doesn't change.HashContext.hppare reused in #1101 and #1103.2.0.0-next.Nunder the npmnexttag, pinned to an exact Nitro Modules v1 nightly. Merge tomainonce Nitro Modules v1 is stable and either CocoaPods support lands (margelo/nitro#2054) or we decide to require Swift packages.The research and the decisions are complete, so this issue is closing. Follow-up work is in the milestone; #1106 (example app on RN 0.88) is next.