> ## Documentation Index
> Fetch the complete documentation index at: https://patch.codemagic.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Migrating from CodePush

> Move from a CodePush-compatible fork or hosted successor to Codemagic Patch.

Patch keeps the familiar apps / deployments / `sync()` model of CodePush, but adds extra capabilities, including:

- Fingerprinting that ensures releases are compatible with the native binary
- A dashboard for release management and adoption metrics
- Update checks that go to the CDN instead of the server

Not all CodePush forks are the same, but the steps below map the usual concepts and walk the cutover. For the full trade-off table, see [How Patch compares](/docs/introduction/comparison#vs-codepush-forks).

Patch is designed to be simple to self-host, but if you would prefer us to host it then email [sales@codemagic.io](mailto:sales@codemagic.io).

  <TabItem value="react-native" label="React Native">

The steps below replace a React Native CodePush-compatible SDK with `@codemagic/react-native-patch`.

  </TabItem>
  <TabItem value="capacitor" label="Capacitor">

CodePush-compatible clients support React Native only. If you use Ionic Appflow Live Updates, see [Migrating from Appflow](/docs/migration/migrating-from-appflow).

  </TabItem>
</SdkTabs>

:::warning
The Patch SDK ships in the native binary. Plan a store release (or internal distribution build) that embeds Patch before OTA updates can run through your Patch server. You cannot swap the update client purely over the air.
:::

## Concept mapping

  <TabItem value="react-native" label="React Native">

| CodePush fork (typical) | Codemagic Patch |
| --- | --- |
| Hosted or self-hosted CodePush-compatible server | Your Patch stack ([self-host](/docs/install) or [Codemagic-hosted](/docs/introduction/pricing#hosted-by-codemagic)) |
| App access key / service token | OAuth sign-in (CLI/dashboard) + `cm_pat_…` API tokens (CI/automation) |
| Deployment key in native config | `CodemagicPatchDeploymentKey` ([same idea](/docs/setup/native-setup#create-apps-and-deployments)) |
| `Staging` / `Production` deployments | Same channel names by default |
| `codePush.sync()` / HOC wrapper | [`sync()` / `Patch.wrap(App, options?)`](/docs/setup/checking-for-updates) from `@codemagic/react-native-patch` |
| `release-react` (CodePush CLI) | `cmpatch release-react` |
| `--mandatory`, rollout, target binary version | Same flags on `cmpatch release-react` / `release patch` |
| `notifyAppReady()` | Called automatically by `sync()`; [manual](/docs/setup/manual-control) if not using `sync()` |

Install modes (`ON_NEXT_RESTART`, `IMMEDIATE`, etc.) and `mandatoryInstallMode` map closely, see [Applying updates](/docs/setup/applying-updates).

  </TabItem>
  <TabItem value="capacitor" label="Capacitor">

| CodePush fork (typical) | Codemagic Patch (Capacitor) |
| --- | --- |
| Hosted or self-hosted CodePush-compatible server | Your Patch stack ([self-host](/docs/install) or [Codemagic-hosted](/docs/introduction/pricing#hosted-by-codemagic)) |
| App access key / service token | GitHub OAuth (dashboard) + `cm_pat_…` API tokens (CLI/CI) |
| Deployment key in native config | `deploymentKey` in `capacitor.config.ts` (`plugins.CodemagicPatch.{ios,android}`) |
| `Staging` / `Production` deployments | Same channel names by default |
| HOC wrapper / automatic sync on start and resume | [`start({ checkFrequency })`](/docs/setup/checking-for-updates) from `@codemagic/capacitor-patch` |
| `codePush.sync()` | [`sync()`](/docs/setup/checking-for-updates) |
| `release-react` (CodePush CLI) | `cmpatch-capacitor release create --bundle-path www` after your web build |
| `--mandatory`, rollout, target binary version | Same flags on `cmpatch-capacitor release create` / `release patch`. `--target-binary-version` is required and must be exact |
| `notifyAppReady()` | Called automatically by `start()` and `sync()`; [manual](/docs/setup/manual-control) if you use neither |

Install modes (`ON_NEXT_RESTART`, `IMMEDIATE`, `ON_NEXT_RESUME`, `ON_NEXT_SUSPEND`) and `mandatoryInstallMode` work the same way; see [Applying updates](/docs/setup/applying-updates). `InstallMode` and `CheckFrequency` are exported as constants, and string literals are also accepted.

  </TabItem>
</SdkTabs>

## 1. Stand up Patch

Follow [Install](/docs/install) (or the [Local quickstart](/docs/local-quickstart) to try the stack locally first). If Codemagic hosts your instance, skip Install and use the URLs you were given. You need:

  <TabItem value="react-native" label="React Native">

- API URL → `CodemagicPatchApiUrl`
- Download base URL → `CodemagicPatchDownloadBaseUrl`

Create apps to mirror your CodePush layout (one app per platform is the usual pattern). From your project root, `cmpatch init` connects to the server, signs you in, creates one app per platform, and links the project:

```bash
cmpatch init
cmpatch deployment list --app MyApp-iOS --format table
```

  </TabItem>
  <TabItem value="capacitor" label="Capacitor">

- API URL → `apiUrl`
- Download base URL → `downloadBaseUrl`

Create one app per platform with `cmpatch-capacitor`. To install the CLI, see [Native setup](/docs/setup/native-setup-capacitor#install-the-cli-and-the-sdk).

```bash
cmpatch-capacitor login --server-url https://updates.example.com
cmpatch-capacitor app create --name MyApp-iOS --server-url https://updates.example.com
cmpatch-capacitor app create --name MyApp-Android --server-url https://updates.example.com
cmpatch-capacitor deployment list --app MyApp-iOS --server-url https://updates.example.com
```

  </TabItem>
</SdkTabs>

Copy each deployment key into config when you integrate the SDK:

  <TabItem value="react-native" label="React Native">

`Info.plist` / `strings.xml`, or the Expo config plugin. See [Native setup](/docs/setup/native-setup).

  </TabItem>
  <TabItem value="capacitor" label="Capacitor">

`capacitor.config.ts` under `plugins.CodemagicPatch.ios` / `.android`. See [Native setup](/docs/setup/native-setup-capacitor).

  </TabItem>
</SdkTabs>

## 2. Replace the client SDK

  <TabItem value="react-native" label="React Native">

Remove your CodePush client package and native wiring (package name varies by fork):

```bash
yarn remove @code-push-next/react-native-code-push   # or your fork's package
```

While CodePush is still referenced from the native hosts, the wiring `cmpatch init` runs reports it as a conflict and leaves the native and JavaScript steps for later; once it is gone, run `cmpatch wire` to install the SDK, run `pod install` (CocoaPods projects; in [React Native SwiftPM mode](/docs/setup/native-setup#ios-swiftpm), `npx react-native spm` instead), and apply the native changes described in [Native setup](/docs/setup/native-setup).

Replace CodePush calls in JS (example uses `@code-push-next`; adjust the import for your fork):

```tsx
// Before (CodePush)

codePush.sync({ installMode: codePush.InstallMode.ON_NEXT_RESTART });

// After (Patch)

void sync({ installMode: InstallMode.ON_NEXT_RESTART });
```

If you used the `codePush(...)(App)` HOC, replace it with `Patch.wrap(App, options)`:

```diff
- import codePush from "@code-push-next/react-native-code-push";
+ import * as Patch from "@codemagic/react-native-patch";

- export default codePush({ installMode: codePush.InstallMode.ON_NEXT_RESUME })(App);
+ export default Patch.wrap(App, { installMode: Patch.InstallMode.ON_NEXT_RESUME });
```

The wrapper is for basic automatic updates: it renders your root immediately and calls `sync()` after mount. `checkFrequency` accepts `"ON_APP_START"` (default) or `"ON_APP_RESUME"` (mount plus foreground return). Use `Patch.CheckFrequency` and `Patch.InstallMode` constants, or their string values; do not reuse CodePush's numeric constants or copy the old options object wholesale.

For progress UI, user confirmation, or readiness that depends on asynchronous initialization, use direct APIs instead of the wrapper. See [Manual control](/docs/setup/manual-control). The [wrapper reference](/docs/reference/sdk-reference#wraproot-options) covers its props, refs, and lifecycle.

  </TabItem>
  <TabItem value="capacitor" label="Capacitor">

Install `@codemagic/capacitor-patch` with `npm install @codemagic/capacitor-patch` and run `npx cap sync`; see [Native setup](/docs/setup/native-setup-capacitor#install-the-cli-and-the-sdk). Then set `deploymentKey`, `apiUrl`, and `downloadBaseUrl` for each platform in `capacitor.config.ts`.

Replace CodePush automatic sync with a call to `start()` after the first screen renders:

```ts

start({
  checkFrequency: CheckFrequency.ON_APP_RESUME,
  installMode: InstallMode.ON_NEXT_RESTART,
});
```

`start()` is the Capacitor equivalent of the React Native wrapper and accepts the same options. For progress UI or user confirmation, see [Manual control](/docs/setup/manual-control).

  </TabItem>
</SdkTabs>

### Convert background duration to milliseconds

CodePush's `minimumBackgroundDuration` is in **seconds**; Patch's is in **milliseconds**. Convert the value when migrating `ON_NEXT_RESUME` or `ON_NEXT_SUSPEND`:

```diff
- minimumBackgroundDuration: 60,     // CodePush: one minute
+ minimumBackgroundDuration: 60_000, // Patch: one minute
```

Keeping `60` would reduce the threshold to 60 milliseconds. This option controls installation timing, not how often you check for updates; see [Applying updates](/docs/setup/applying-updates#minimumbackgroundduration).

  <TabItem value="react-native" label="React Native">

### Replace a MANUAL wrapper without losing readiness confirmation

The legacy `codePush({ checkFrequency: codePush.CheckFrequency.MANUAL })(App)` wrapper still called `notifyAppReady()` on mount. Patch has no `MANUAL` wrapper policy. Remove the wrapper and preserve that startup responsibility separately from your user-triggered checks:

```tsx

export default App; // no update wrapper

// Call from your successful startup path, after required initialization.
async function onAppStarted() {
  await Patch.notifyAppReady();
}

// Connect separately to your "Check for updates" button.
async function onCheckForUpdates() {
  const status = await Patch.sync();
  return status; // Use the result in your UI.
}
```

Do not wait for the user to press the button to confirm readiness: an unconfirmed healthy update can eventually roll back after repeated launches without confirmation. If your startup path already calls `sync()` after initialization succeeds, it confirms readiness itself and no separate `notifyAppReady()` call is needed.

### Move custom behavior to direct APIs

The legacy HOC discovered methods on the wrapped class component; these were not callback fields in its options. Choose the manual integration that matches what those methods did:

| Legacy behavior | Patch migration |
| --- | --- |
| `codePushDownloadDidProgress` | Use `sync(options, onProgress)` for download progress; see [progress and status](/docs/setup/checking-for-updates#download-progress-and-status). |
| `codePushStatusDidChange` for completion or errors | Await `sync()` and handle its returned status. Patch returns status strings, not CodePush's numeric `SyncStatus` values. |
| `codePushStatusDidChange` for checking / downloading / installing UI | Update your UI around each direct API call; see the [manual example](/docs/setup/manual-control#stage-specific-ui). `sync()` does not expose intermediate status callbacks. |
| `updateDialog` | Show your own confirmation UI before download or installation using [manual control](/docs/setup/manual-control). |
| `codePushOnBinaryVersionMismatch` | Use `checkForUpdate()` and its store-version fields; see [store updates](/docs/setup/checking-for-updates#binary-version-mismatch-and-store-updates). `sync()` returns only a status. |
| Custom static properties on the wrapped component | `wrap()` does not hoist them. Keep the original component where consumers need its statics, or explicitly expose the properties your integration requires. |
| Per-call `deploymentKey` override | Not supported by Patch's JS APIs. Configure deployment keys in the native build; see [per-build configuration](/docs/using-patch/preparing-for-production#3-tune-client-sync-by-build). Apps that switch deployments at runtime need to revise that integration. |
| `ignoreFailedUpdates` / `rollbackRetryOptions` | No equivalent `sync()` options. Patch's `sync()` skips packages marked `previouslyFailed`; it does not provide CodePush's configurable rollback retry policy. |

Use one owner for automatic checks. When replacing the wrapper with manual lifecycle code, remove `Patch.wrap()` rather than adding a second `sync()` call to observe its work: overlapping calls return `"sync-in-progress"` and do not attach callbacks to the running operation.

  </TabItem>
  <TabItem value="capacitor" label="Capacitor">

There is no wrapper component. `start()` marks the running bundle as healthy when called, so call it after the first screen renders, or after asynchronous initialization completes. If you replace `start()` with a manual flow, call `notifyAppReady()` on every successful startup. Progress UI, confirmation dialogs, and store update prompts use the same [manual APIs](/docs/setup/manual-control) as React Native. Per-call `deploymentKey` overrides are not supported; set keys in `capacitor.config.ts`.

  </TabItem>
</SdkTabs>

## 3. Point CI at Patch

  <TabItem value="react-native" label="React Native">

Install and authenticate the Patch CLI:

```bash
npm install -g @codemagic/patch-cli
cmpatch token create --name ci   # store cm_pat_… as a CI secret
```

Commit the `codemagic-patch.config.json` that `cmpatch init` wrote, and CI
needs only the token; without it, set `CODEMAGIC_PATCH_SERVER_URL`.

  </TabItem>
  <TabItem value="capacitor" label="Capacitor">

Create a CI token and store the `cm_pat_…` value as a secret:

```bash
cmpatch-capacitor token create --name ci --expires-in-days 365
```

Set `CODEMAGIC_PATCH_TOKEN` and `CODEMAGIC_PATCH_SERVER_URL` in the pipeline. There is no project config file to commit.

  </TabItem>
</SdkTabs>

Swap your fork's release / `release-react` CI steps for:

  <TabItem value="react-native" label="React Native">

```bash
cmpatch release-react \
  --platform ios \
  --deployment Production \
  --release-notes "…" \
  --yes
```

  </TabItem>
  <TabItem value="capacitor" label="Capacitor">

```bash
cmpatch-capacitor release create \
  --bundle-path www \
  --app MyApp-iOS \
  --deployment Production \
  --target-binary-version "1.2.0" \
  --release-notes "…" \
  --yes
```

  </TabItem>
</SdkTabs>

See [CI integration](/docs/using-patch/ci-integration).

## 4. Cut over

  <TabItem value="react-native" label="React Native">

1. **Publish a native build** with the Patch SDK and deployment keys embedded (Staging first).
2. **Publish an OTA release** to that deployment with `cmpatch release-react` targeting the same binary version users install.
3. Validate on Staging, then repeat for Production.
4. Decommission the old CodePush server or SaaS once no active binaries still call it.

  </TabItem>
  <TabItem value="capacitor" label="Capacitor">

1. **Publish a native build** with the Patch SDK and deployment keys embedded (Staging first).
2. **Publish an OTA release** to that deployment with `cmpatch-capacitor release create --bundle-path www` targeting the same binary version users install.
3. Validate on Staging, then repeat for Production.
4. Decommission the old CodePush server or SaaS once no active binaries still call it.

  </TabItem>
</SdkTabs>

## Checklist

  <TabItem value="react-native" label="React Native">

- [ ] Patch server running with HTTPS and an OAuth sign-in provider configured
- [ ] Apps and deployments created; keys copied into native config
- [ ] CodePush package and native wiring removed; Patch SDK integrated
- [ ] `Patch.wrap()`, `sync()`, or manual APIs replace CodePush sync/HOC
- [ ] Background duration converted to milliseconds; Patch constants replace CodePush constants
- [ ] Startup readiness preserved when removing a `MANUAL` HOC
- [ ] Legacy callbacks, custom statics, and unsupported options reviewed against the migration table
- [ ] CI secrets and release commands updated to `cmpatch`
- [ ] New store/internal binary shipped; OTA tested on Staging before Production

  </TabItem>
  <TabItem value="capacitor" label="Capacitor">

- [ ] Patch server running with HTTPS and an OAuth sign-in provider configured
- [ ] One Capacitor app per platform created; keys copied into `capacitor.config.ts`
- [ ] `@codemagic/capacitor-patch` installed and `npx cap sync` run
- [ ] `start()`, `sync()`, or manual APIs replace CodePush-style sync
- [ ] Background duration converted to milliseconds
- [ ] Startup readiness confirmed with `start()`, `sync()`, or `notifyAppReady()`
- [ ] Unsupported options (per-call `deploymentKey`, rollback retry policy) reviewed
- [ ] CI secrets and release commands updated to `cmpatch-capacitor`, with an exact `--target-binary-version`
- [ ] New store/internal binary shipped; OTA tested on Staging before Production

  </TabItem>
</SdkTabs>
