JavaScript Bundle

Also called JS bundle, Bundle

Updated

What is JavaScript Bundle in React Native?

The JavaScript bundle is the single file Metro produces from your source code. It ships inside the app binary and is what the JavaScript engine actually executes.

Metrobundle.jsstartup
Your code, and the bundlenode_modulesBundle on its wayMetro collapses your code and every npm dependency into one file. In development Metro serves it over HTTP and the app fetches it at launch, which is why Metro must be running. In a release build it is written into the binary, as main.jsbundle on iOS or index.android.bundle on Android, precompiled to Hermes bytecode. Everything in it is loaded at launch, so an unused 2 MB dependency still costs startup. Sizes here are illustrative. The bundle is also the line over-the-air updates can cross; anything outside it needs a store build.

The JavaScript bundle is the compiled output of your entire application's JavaScript — your code plus every npm dependency — collapsed by Metro into one file.

Where it lives depends on the build:

  • Development — served over HTTP by the Metro dev server and fetched on launch, which is why the app needs Metro running.
  • Release — written into the binary as main.jsbundle (iOS) or index.android.bundle (Android), and precompiled to Hermes bytecode.

Two consequences worth internalising as a newcomer.

Bundle size affects startup, not download size, in the way you might expect — the bundle is a small fraction of an app binary, but everything in it is parsed or loaded at launch, so an unused 2MB dependency still costs you.

And the JS/native split is exactly this file. Changing bundle contents can ship as an over-the-air update; changing anything outside it requires a new store build.