loading...

React Native Bridge

thomaswilfred15 profile image Thomas Wilfred ・2 min read

React Native is an open-source application created by Facebook and used for developing native applications for mobile phones. It is famous among developers for its user-friendly UI and its effectiveness. Along with that, it is very similar to ReactJS.

React Native consists of two parts:

  1. Native Modules.
  2. Native UI Components.

Native Modules

A Native Module is just a set of javascript functions that are implemented natively for the individual platform. Native Modules are used when React Native doesn’t have that required module yet, or when the native performance is significantly better.

Native UI Components

There are tons of native UI widgets out there ready to be used in the latest apps - some of them are part of the platform, others are available as third-party libraries, and still, more might be in use in your very own portfolio.

With the introduction part done, let us discuss the concept of React Native Bridge.

The bridge is the concept responsible for bidirectional communication between the two interfaces- front end and back end. The intriguing par among all this is that they are written in different technologies but are able to communicate with each other.

If we want these two services to communicate, we rely on a message queue. The first service pushes some commands inside the queue and the other one has to execute these commands when possible.

React Native behaves the same way. The JavaScript realm sends asynchronous JSON messages describing the action the Native part is supposed to accomplish.

In React Native, the bridge endorses as the message broker, handling commands between the two interfaces.

The Bridge Implementation

The bridge is built in C/C++ and hence, can be run on multiple platforms, OS, etc.

It embeds the Apple JavaScriptCore framework, which exposes APIs to access the actual JavacriptCore VM capabilities. Many people use these APIs in the Objective-C and Swift world. But there is a C API, and the Objective-C one is actually just a wrapper.

Now, React Bridge Implementation can be done for Android as well as iOS

  1. Create React Native Bridge for iOS.

  2. Create React Native Bridge for Android.

Discussion

pic
Editor guide