Tech

7MB to 100KB: Shrinking React Native OTA Updates

A small in-house experiment to use Hermes, CodePush, and bsdiff to ship tiny OTA patches instead of full React Native bundles.

Mihir Karandikar·December 10, 2025·5 min read

At udaan, we run a fairly standard React Native setup: Hermes turned on, CodePush handling over-the-air updates, releases rolling out without much drama.

I'd already spent time shrinking the bundle itself (more on that in Smaller Bundles and Faster Pipelines), and that work paid off. But towards the end of that cleanup, every extra tweak gave smaller and smaller wins.

At that point I started looking for a different kind of lever: not just “how small can I make the bundle?”, but “how small can I make each update?”. Shipping binary diffs is a well-known trick; plenty of systems already send patches instead of full binaries - browsers, game launchers, native updaters and a few React Native teams like Quizzap and Zepto. A small POC felt like a good way to explore this space inside the stack we were already running at udaan.

Hermes bytecode and bsdiff - briefly

Hermes is a JavaScript engine optimised for the modern React Native stack. Metro produces a plain JS bundle, and Hermes compiler turns it into a .hbc bytecode file that the runtime can execute directly.

Instead of source code, that file holds string tables, constant pools, and compiled function bodies wired together by offsets - a compact, engine-friendly representation of your app. To help you visualise, here's a hex dump of a binary file using hexyl. There's no concept of “lines” or “tokens” here - Just raw bytes.

A hexyl hex dump of a small PNG file in a terminal, with the bytes on the left and their text on the right.

Diffing that kind of file is different from diffing text. A regular line-based diff doesn't make sense on binary data. This is where bsdiff fits nicely: it compares two versions of a file at the byte level, finds matching and non-matching regions, and encodes “keep this range, replace this range with these bytes” into a small binary patch. It doesn't care whether the file is an executable, an image, or a Hermes .hbc blob. As long as most of the bytes are the same, the patch (delta) it produces tends to be much smaller than the full file.

A diagram of a binary delta: the blocks of an old file, a smaller delta holding only the blocks that changed, and the new file rebuilt from the two.
Original diagram credits to Jonathan Dieter.

Computing the patch

The bsdiff algorithm was originally written by Colin Percival for updating large binary executables on FreeBSD systems. It's tuned to favour very small patch sizes over raw speed, which is a good trade-off when you care more about bytes sent over the network than a few extra seconds of CPU at the build stage.

In this experiment I used the C implementation at mendsley/bsdiff. It's small, easy to compile in CI, and perfectly happy diffing 10–20 MB Hermes bundles. The release job just invokes it on the previous and current bundles and stores the resulting patch.bsdiff file alongside the full bundle so it can be served too.

Once that wiring is in place, actually generating a patch is straightforward:

  1. Take the Hermes bundle I already shipped (old.hbc).
  2. Build a new Hermes bundle (new.hbc) with the latest code.
  3. Run bsdiff old.hbc new.hbc patch.bsdiff.
  4. Ship patch.bsdiff to the device and apply it with bspatch on the device.

Conceptually, the client only has to do this:

TEXT
(old .hbc) + patch  =  (new .hbc)

I hit a snag

But when I tried to create a patch locally, the patch file came out almost as big as the new bundle.

A table of artifact sizes: both Hermes bundles are 6.83 MB, and the bsdiff patch between them is 5.76 MB.

I tried again with an even smaller change - tweaking a string, adding a tiny branch - and the patch size barely moved. I double‑checked that I was diffing the right files, that both bundles were built with the same flags, and even tested bsdiff on a couple of simpler binaries just to make sure I wasn't misusing it.

For a moment it felt like the whole idea was dead in the water - that maybe my assumptions about “small change → small patch” just didn't apply here.

But eventually I figured it out!

What I eventually realised is that Hermes bytecode is not a stable “text file with a few lines changed”. The file layout can move around between builds in ways that are invisible at the JavaScript level but very visible to a binary diff tool:

  • Strings and function bodies can be reordered,
  • Offsets and tables can shift even for tiny source changes,

So a small JS edit can lead to large, noisy differences in the .hbc bytes.

The fix turned out to be on the Hermes side, not in the diff tool. Hermes has a flag called --base-bytecode that lets you compile the new bundle using the previous .hbc file as a base, so string tables and layout stay aligned across builds. Once I started invoking hermesc with --base-bytecode <old.hbc> before running bsdiff, patches finally behaved the way I expected: small JS changes turned into small, predictable binary diffs.

A table of artifact sizes: the Hermes bundles are 12.01 MB, the patch without a base is 0.94 MB, and the patch with a base is 0.12 MB.

Where I'm leaving this experiment

So the POC works, both conceptually and in practice: with --base-bytecode in place, bsdiff can produce tiny, stable patches between Hermes bundles, and it's straightforward to wire that into a CI job.

But turning that into a real feature inside udaan's OTA pipeline would involve a lot more than just diffing. We'd need:

  • CLI shim that always emits bundle hashes and patches,
  • Server that understands base and target hashes and can serve patches safely,
  • Client that can apply them with proper signing and rollback, and
  • Operational pieces around telemetry, kill switches, and incident response.

That's roughly the shape of the internal rollout plan I sketched.

For now, I'm happy treating this as an experiment that deepened my understanding of Hermes, CodePush, and OTA updates. Whether we ship this as a product feature is a separate decision - and one that lives at the intersection of engineering effort, risk, and how much bandwidth we're actually saving in the real world.