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 } 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({
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}
/>
);
}