init
`HotUpdater.init` initializes HotUpdater for manual update flows without wrapping a React component.
Usage
Use HotUpdater.init when you want a fully custom update flow and cannot, or do
not want to, wrap your root component with HotUpdater.wrap. Call it once when
your runtime considers the app ready. This API exists for apps that only need
Hot Updater initialization and do not need the extra React HOC created by
manual HotUpdater.wrap.
HotUpdater.init is equivalent to
HotUpdater.wrap({ updateMode: "manual" })(App) without the HOC.
import { HotUpdater } from "@hot-updater/react-native";
HotUpdater.init({
baseURL: "<your-update-server-url>",
requestHeaders: {
Authorization: "Bearer <your-access-token>",
},
});After initialization, call HotUpdater.checkForUpdate() wherever your runtime
or app state says it is safe to check.
const updateInfo = await HotUpdater.checkForUpdate({
updateStrategy: "appVersion",
});
if (!updateInfo) {
return;
}
await updateInfo.updateBundle();
if (updateInfo.shouldForceUpdate) {
await HotUpdater.reload();
}Configuration Reference
| Option | Type | Required | Description |
|---|---|---|---|
baseURL | string | Yes | Your update server URL |
requestHeaders | Record<string, string> | No | Shared headers used by update checks and app-ready notifications |
requestTimeout | number | No | Request timeout in milliseconds (default: 5000) |
onNotifyAppReady | (result) => void | No | Callback invoked after native app-ready state is read |
When to Use init
Use HotUpdater.init when another runtime owns the root component, when you
need to initialize before rendering, or when your app has a custom shell that
does not make a root HOC convenient.
Use HotUpdater.wrap when you want Hot Updater to manage the root component
lifecycle directly, especially for automatic update checks with a fallback UI.
Related
wrap
`HotUpdater.wrap` checks for updates at the entry point, and if there is a bundle to update, it downloads the bundle and applies the update strategy.
checkForUpdate
The `checkForUpdate` function checks if there is an available update for the app by comparing the current app version and platform with the update server's bundle information.