[0.74] Bridgeless By Default #174
cipolleschi
started this conversation in
Releases
Replies: 2 comments 7 replies
-
Hey! Could you share what will change for user experience? Are there any numbers on performance/start up time/crashes/etc. difference between bridged and bridgeless modes? |
Beta Was this translation helpful? Give feedback.
5 replies
-
Hi there, Two questions(apologies, the docs seem to not address this so far)
ps: The C++ turbo modules guide used to be visible from the main react-native docs page, but has now inexplicably vanished from there. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Important
tl;dr: With React Native 0.74, we’re going to enable Bridgeless by default, as long as you enable the New Architecture
As we roll out the New Architecture of React Native in Open Source, we want to share an update on Bridgeless Mode. Starting from 0.74, Bridgeless will be enabled by default only when the New Architecture is enabled.
The New Architecture remains experimental and you need to explicitly enable it in your applications.
This marks an important milestone for React Native, as Bridgeless was the last piece of the New Architecture, and we managed to open source it in React Native 0.73, but it was still behind a flag. Now, we removed that flag and it will be enabled by default when the new architecture is enabled.
Now, you can experience the New Architecture at full power in your React Native app. We need your help to iron out the latest details, so please, open an issue on React Native every time you find something that is not working as expected in the New Architecture.
How to enable it and what does it mean?
As this post's title suggests, you don’t have to do anything to experience Bridgeless but to turn on the New Architecture. To enable it, follow the instructions in the New Architecture documentation:
How to check that Bridgeless is enabled?
Once the app is running, you can verify that Bridgeless is enabled by looking at the Metro logs. When Bridgeless is enabled, you should see logs that look like this:
What to expect?
Your App should run seamlessly in Bridgeless mode, provided that it was running with the old Architecture before.
We spent a lot of time working on interop layers and on bringing the Bridge API you might have used to Bridgeless mode. You can read more about it in the Backward Compatibility section below.
However, we know that there might still be some missing APIs and some rough edges that we need to iron before stating that the New Architecture is the new default.
We need your help!
Whenever you find something that does not work as expected, please submit an issue to the React Native repo, using the New Architecture issue template.
We are prioritizing working on the New Architecture and those bugs have the highest priority for us.
Opting-out of Bridgeless
Although we consider Bridgeless an integral part of the New Architecture, we are still providing the possibility to disable it, while keeping all the other bits of the New Architecture turned on: Codegen, New Native Module system (Turbo Native Modules), New Renderer (Fabric).
We are not going to support this combination in the long term, so we are not suggesting to use it effectively. But, in some cases, it could be helpful to disable Bridgeless to debug some features or to verify that there is a disparity between Bridge and Bridgeless.
To disable Bridgeless mode only, follow these steps:
Android
<your-project>/app/src/main/java/com/<your-project>/MainApplication.kt
fileonCreate
methodiOS
<your-project>/ios/<your-project>/AppDelegate.mm
bridgelessEnabled
method by adding the following code:Verify that the app is running with the New Architecture in Bridge mode
Once you run the step above for either Android or iOS and the app is running, you can check the Metro logs to verify whether the app is running with Bridgeless turned off.
The Metro’s logs should look like this:
As you can see, the tag
(NOBRIDGE)
is not rendered, but React Native is running withconcurrentRoot
set totrue
, which is a distinctive feature of the New Architecture.Backward Compatibility
To ensure that projects can migrate smoothly to the New Architecture and to Bridgeless, we dedicated a lot of time to interoperability and backward compatibility. Specifically we:
In the following sections, we will explore more in depth the APIs we brought back and the current known limitations of Bridgeless.
The Interop status as of React Native 0.73
We started working on interop layers and backward compatibility way back, even before React Native 0.73. As a refresher:
This line of work already allowed you to use several APIs that were available in the Old Architecture in the new one. However we were aware that something was still missing.
New API introduced in 0.74
In 0.73, we were not able to support all the API we wanted. We listed the APIs we knew were not working properly in the post for 0.73 to let you know what you could use and what not.
In 0.74, we fixed some of those missing APIs and added more layer of backward compatibility to let you migrate to the New Architecture with more ease.
For this version of React native, we focused more on Android APIs
ReactActivity.getReactDelegate()
The
ReactDelegate
you can obtain from theReactActivity
is now supporting some other methods that were not supported in 0.73:The
reload()
method, specifically, requires some extra details: we introduced it with the purpose of replacing direct calls toReactInstanceManager.
recreateReactContextInBackground()
. So, if your NativeModule was usingrecreateReactContextInBackground
, you can now replace it with a simplerreload()
method call.ReactContext.getCatalystInstance
To improve backward compatibility between the New and Old Architecture, we brought back the
getCatalystInstance()
method of the React Context.The method now returns a
BridgelessCatalystInstance
which supports the following methods:getJSCallInvokerHolder()
getRuntimeExecutor()
getJavaScriptContextHolder()
Beta Was this translation helpful? Give feedback.
All reactions