HotCodePush

Installation

Set up @hotcodepush/capacitor-live-updates with an AI agent, with npx hotcodepush init or by hand in five steps, then check the setup with doctor.

Install @hotcodepush/capacitor-live-updates in one of three ways: let an AI agent do it, run npx hotcodepush init, or follow the steps by hand. You need a Capacitor app with its native projects, Node on the machine that builds it and an app in the console.

Install the HotCodePush skills:

npx skills add hotcodepush-team/skills

Then paste the prompt into your coding agent:

Set up HotCodePush in this project: install the skills with `npx skills add hotcodepush-team/skills`, then run the hotcodepush-init skill and the hotcodepush-release skill, following https://hotcodepush.com/docs/ai.

The agent installs the SDK, creates the app and ships a first update. Agent skills explains what the agent does.

Set up with the CLI

npx hotcodepush init

init installs the package, writes hotcodepush.json, wires the build step and signs you in. The init reference lists every step and the manual step it hands you when it cannot edit a file. Run it again after a manual step: it finishes only what is missing.

Manual setup

If init already ran, skip to step 5.

1. Install the package

npm install @hotcodepush/capacitor-live-updates
npm install --save-dev hotcodepush
npx cap sync

The CLI is a dev dependency: the build step runs npx hotcodepush inside every native build. An iOS app on CocoaPods adds the core's pod to its Podfile:

ios/App/Podfile
pod 'HotCodePushCore'

2. Add hotcodepush.json

hotcodepush.json
{
  "appId": "4f2b7c9e-8d31-4a6e-9b0f-2c5d7e8a1b34",
  "channel": "production"
}

appId is on the app's page in the console, and channel is the channel this build follows. Every other key has a default. Configuration lists them.

3. Wire the build step

The build step writes hotcodepush.json into the built app on every build and, in a store build, creates the binary. binary says what it writes and needs. A store build needs npx hotcodepush login or HOTCODEPUSH_TOKEN in the build's environment.

Append one line at the end of android/app/build.gradle:

android/app/build.gradle
apply from: new File(["node", "--print", "require.resolve('@hotcodepush/capacitor-live-updates/package.json')"].execute(null, rootDir).text.trim(), "../android/hotcodepush.gradle")

A project on build.gradle.kts takes the same line in Kotlin syntax:

android/app/build.gradle.kts
apply(from = File(providers.exec { workingDir(rootDir); commandLine("node", "--print", "require.resolve('@hotcodepush/capacitor-live-updates/package.json')") }.standardOutput.asText.get().trim()).resolveSibling("android/hotcodepush.gradle"))

npx must be on the PATH of the shell or IDE that runs Gradle.

4. Import the package at start

Import the package in the app's entry file: the import runs the SDK at every start and reports the first render, the readiness signal under readySignal: render. Linters, formatters and bundlers keep a side-effect import, while a lint autofix removes a named import that nothing uses. An app that imports HotCodePush to call methods needs no second import: any import of the package runs it.

src/main.ts
// Starts the SDK and reports readiness; nothing references it on purpose.
import '@hotcodepush/capacitor-live-updates';

5. Build and verify

npm run build
npx cap sync
npx hotcodepush doctor

Run the app from Xcode or Android Studio. doctor reports each check as ok, skipped or failed, with the step that repairs a failure. doctor lists the checks.

6. Release a first update

Change something visible in the web app, build it and release it to the channel:

npm run build
npx hotcodepush release create

The device applies the release at its next start. release has every option. If nothing happens, see Troubleshooting.

Platform notes

  • Builds: a run from the IDE, a simulator build and a local Release build create no binary, while an archive or a non-debug Gradle build does. The first update of a build without a binary is the full pack. A debug build embeds the web assets and takes updates by default. Set isEnabledInDebugBuilds to false once the setup is verified.
  • Android: the SDK's manifest declares INTERNET and ACCESS_NETWORK_STATE, nothing to add. An app that sets android:fullBackupContent or android:dataExtractionRules itself hits a manifest merger conflict. Keep your rules, add tools:replace for the attribute on <application>, and exclude hotcodepush/ under domain="file" in both <cloud-backup> and <device-transfer>.
  • Web: the package ships no web implementation, so every method rejects with Capacitor's UNIMPLEMENTED error. Guard the calls as Errors shows.
  • Live reload serves the page from the dev server, so a downloaded release changes nothing you see. A location.reload() applies nothing either: a next_start release waits for the next process start.
  • Privacy: the SDK ships its privacy manifest, nothing to add. Privacy and device data has the App Privacy answers.

Next steps

  • Configuration lists every key of hotcodepush.json and the strategies that decide when an update is checked, downloaded and applied.
  • API documents the methods, events and types, with the statuses and reasons a result carries.
  • Sign your bundles sets up a key pair whose public key goes into hotcodepush.json, so a device refuses a bundle you did not sign.

Last updated on

On this page