React Native API
isUpdateDownloaded
Returns whether an update bundle has finished downloading in the current app session and is ready to be applied on reload.
Usage
- Returns
truewhen the downloadprogresshas reached1.0. - Returns
falsewhile downloading or before any download starts. - Resets to
falseautomatically when a new download starts.
import { HotUpdater } from "@hot-updater/react-native";
async function maybeApplyUpdate() {
if (HotUpdater.isUpdateDownloaded()) {
await HotUpdater.reload();
}
}Skip checkForUpdate when a download already exists
If a bundle has already finished downloading in this session, you can skip checkForUpdate() and just prompt the user to reload.
import { HotUpdater, getUpdateSource } from "@hot-updater/react-native";
async function checkAndUpdate() {
// Avoid network call if an update is already downloaded and awaiting reload
if (HotUpdater.isUpdateDownloaded()) {
// e.g., show a "Restart to update" CTA or reload immediately
return;
}
const updateInfo = await HotUpdater.checkForUpdate({
source: getUpdateSource("<your-update-server-url>", {
updateStrategy: "appVersion", // or "fingerprint"
}),
// requestHeaders: { Authorization: "Bearer <token>" },
});
if (!updateInfo) return;
const ok = await updateInfo.updateBundle();
if (!ok) return;
if (updateInfo.shouldForceUpdate) {
await HotUpdater.reload();
}
}Details
- This value is derived from the internal
progressstate managed byuseHotUpdaterStore(). - It is session-scoped: it does not persist across app restarts.
- Use this when you need to decide whether to show a "Restart to update" UI or trigger a controlled reload.
import { HotUpdater, useHotUpdaterStore } from "@hot-updater/react-native";
import { Button } from "react-native";
export function UpdateButton() {
const { progress, isUpdateDownloaded } = useHotUpdaterStore();
return (
<Button
title={isUpdateDownloaded ? "Restart to update" : `Updating... ${Math.round(progress * 100)}%`}
onPress={() => HotUpdater.reload()}
disabled={!isUpdateDownloaded}
/>
);
}addEventListener
The `addEventListener` function allows you to listen for specific events emitted by the HotUpdater. This is useful for tracking update progress or other events during the update process.
Supabase Provider
This guide walks you through setting up `hot-updater` with Supabase in a React Native project. You'll configure the environment, install required packages, and initialize Supabase for seamless updates.