HotupdaterHot Updater
React Native API

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 without a React HOC.

import { HotUpdater } from "@hot-updater/react-native";

HotUpdater.init({
  baseURL: "<your-update-server-url>",
  requestHeaders: {
    Authorization: "Bearer <your-access-token>",
  },
  onError: error => {
    console.error("Hot Updater failed", error);
  },
});

baseURL can also be resolved at runtime. The function may return a string or a promise, and Hot Updater calls it before each update check.

HotUpdater.init({
  baseURL: async () => {
    return await getUpdateServerURL();
  },
});

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

OptionTypeRequiredDescription
baseURLstring | () => string | Promise<string>Yes*Your update server URL or runtime URL resolver
resolverHotUpdaterResolverYes*Custom network operations
requestHeadersRecord<string, string>NoShared headers used by update checks and app-ready notifications
requestTimeoutnumberNoRequest timeout in milliseconds (default: 5000)
onNotifyAppReady(result) => voidNoCallback invoked after native app-ready state is read
onError(error) => voidNoDefault error handler for initialization and update checks

*Either baseURL or resolver must be provided (mutually exclusive).

HotUpdater.checkForUpdate({ onError }) overrides the onError handler from HotUpdater.init for that specific update check.

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.

On this page