Binary patches: OTA updates measured in bytes, not megabytes
A one-line fix should not cost every user a full bundle download. BetterCodePush 1.0 sends a binary diff against the bundle the device already runs, and falls back to the full file only when it must.
Most OTA releases are small: a copy fix, a guard against a null, a tweaked layout. But a Hermes bundle is one large file, so a classic OTA update re-downloads all of it for every change. On a slow connection that is the difference between an update that applies on the next launch and one that never finishes.
What 1.0 sends instead
When you run deploy, the CLI compares the new bundle with the releases already live on that channel and builds a bsdiff patch from each of them. A device that runs one of those releases downloads only the patch, rebuilds the new bundle locally, and checks its SHA-256 hash (and signature, if you sign) before using it.
The size of a patch follows the size of your change, not the size of your bundle. A one-line fix to a bundle of several megabytes is typically a download of a few hundred bytes to a few kilobytes.
Only changed files
Bundles are delivered with a manifest of every file and its hash. Images and other assets that did not change are not downloaded again, so a JavaScript-only fix never re-sends your images.
Safe by default
- If the device does not hold a patch base, or a patched file does not match its expected hash, it downloads the full file instead. A patch can make an update faster; it can never make it wrong.
- Patches are built at deploy time, so devices never wait for a diff to be computed.
- Patch bytes are served from the CDN like every other artifact.
Configuration
Patches are on by default and built against the three most recent compatible releases. To change that, set patch in bettercodepush.config.ts:
export default defineConfig({
// ...
patch: { enabled: true, maxBaseBundles: 5 },
})A larger maxBaseBundles helps users who skip several releases between launches, at the cost of a slightly longer deploy.
Smaller downloads also make rollouts more predictable: more devices on a staged rollout actually land on the new release during the soak window. If you are wondering how large a bundle can get before it matters, see how big can a React Native bundle be.