- JSI allows methods, available via
- The methods can be used to communicate with native codes i.e. Java code in Android and Objective-C in iOS.
- Any native module built with a
- On iOS, writing this layer is super easy as C++ code can directly run in Objective-C hence the code can be used directly. While in Android, this execution requires a Java Native Interface.
As seen in the above example, we have to create an instance of the
Value class in the
Here, string variables are created using the
createFromUtf8 method of the
String class in the
How is JSI better than Bridge?
- JSI creates a well-functioning structure when compared to Bridge as it provides both faster and direct access to the JS runtime.
Thus it shows the performance of native modules and applications using native modules improves when the bridges are replaced with JSI methods.
However, since JSI only changes the infrastructure, it won’t affect regular React native applications. While for library maintainers, migrating libraries to JSI could prove useful.