In this lesson, you will learn how the native host application wakes up the JavaScript runtime to begin your React Native application.
From App Launch to JavaScript Execution
When you tap your app icon, the operating system (iOS or Android) does not immediately know what React code is. It starts by launching the "Host Platform"—the native shell written in Swift/Objective-C or Kotlin/Java. Before a single pixel of your UI appears, this host must perform Bootstrapping.
Bootstrapping is the orchestration process where the native side sets the stage for the JavaScript engine. Think of it like a theater production: the native side is the stage manager, and the JavaScript bundle is the script. The stage manager must prepare the stage, turn on the lights, and hand the script to the actors before the play can begin.
The Steps of the Bootstrapper
- Initialization of the React Instance: The native
ReactInstanceis created. This acts as the bridge between your native code and the JavaScript virtual machine. - Setting up the Runtime: The native side initializes the JavaScript engine (like Hermes or V8).
- Loading the Bundle: The host platform locates your compiled JavaScript code (the
index.bundle)—usually stored in the app’s internal assets—and loads it into the engine's memory. - The "Main" Entry Point: The host platform calls a specific instruction to execute the entry point of your JavaScript, usually
AppRegistry.registerComponent.
In your AppDelegate (iOS) or MainActivity (Android), this looks roughly like this:
// The native host prepares the React Root View
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:@"MyAwesomeApp"
initialProperties:nil
launchOptions:launchOptions];
By the time this line finishes, the native host has successfully "bootstrapped" the environment. It has linked the native UI container to the JavaScript engine, allowing the React lifecycle to take over. Without this critical handoff, the JavaScript engine would exist in a vacuum, completely unaware of the native application context surrounding it.
Key Takeaway: Host platform bootstrapping is the essential "handshake" where the native app initializes the JavaScript runtime and loads your bundle into memory so that the two worlds can finally communicate.