# Migrating from CodePush

This guide is for a React Native or Expo app that already publishes updates
with CodePush. It maps CodePush's commands onto their closest Rollbird
equivalent, covers the two places the underlying model differs, and hands off
to Rollbird's own setup and verification steps.

Read [OTA updates explained](https://rollbird.dev/docs/react-native-ota-updates/)
first for the general mechanism — channels, staged rollout, and rollback —
independent of either tool.

## What maps directly

Both tools sign in, link an app to a place updates are published from, ship a
release, and roll one back. CodePush was distributed both as the standalone
`code-push` CLI and as the `appcenter codepush ...` wrapper; the subcommands
below are the same either way. The table lists each CodePush command next to
its Rollbird equivalent. Every Rollbird command and flag below is documented
in the [CLI reference](https://rollbird.dev/docs/cli/).

| CodePush command | Rollbird equivalent |
| --- | --- |
| `code-push login` | `rollbird login` |
| `code-push app add <appName> <os> <platform>` and `code-push deployment add <appName> <deploymentName>` | `rollbird init` |
| `code-push release-react <appName> <platform>` | `rollbird release` |
| `code-push rollback <appName> <deploymentName>` | `rollbird rollback` |
| `code-push deployment ls <appName>` | `rollbird status` |

`rollbird init` does the combined job of CodePush's app and deployment setup:
it links the app to a Rollbird project and embeds a channel in the native
build in one step. Run it once per channel:

```bash
npx rollbird init --channel preview
```

The [Getting started](https://rollbird.dev/docs/getting-started/) guide walks
through this step and the ones that follow in full, including the wrapper
import and the native rebuild.

## What works differently

**Deployment keys become channels.** CodePush issues one deployment key per
deployment — typically `Staging` and `Production` — and a build embeds that
key to say which deployment it requests. Rollbird embeds a channel name in
the same place: `rollbird init --channel preview` or
`rollbird init --channel production` writes the channel into the native
build. A binary only requests the channel it was built with; publishing to a
different channel does not reach it. Treat each CodePush deployment your app
used as one Rollbird channel.

**Update eligibility compares a fingerprint, not a version range.** CodePush's
`release-react` command targets a binary version range through
`targetBinaryVersion`; any installed binary whose app version satisfies that
range is offered the update. Rollbird's default `fingerprint` strategy
instead compares a fingerprint of the native build: `rollbird init` embeds
that fingerprint, and a release only reaches a binary whose native code
produced a matching one. A native dependency change, a native configuration
change, or any other native-affecting edit changes the fingerprint, so
re-run `rollbird init` and rebuild after one. An `appVersion` strategy is
also available for apps that want to target by version instead; see the
[React Native SDK guide](https://rollbird.dev/docs/react-native/#compatibility-strategies).

## Migration steps

Follow [Getting started](https://rollbird.dev/docs/getting-started/) from the
beginning: install the CLI, sign in, run `rollbird init` for each channel
your app used with CodePush, wrap the root component, and rebuild the native
binary. Keep only one update controller active in the app; remove the
CodePush package and its native wiring once the Rollbird-wrapped binary is
built.

## Verifying the migration

Complete steps 7 through 9 of
[Getting started](https://rollbird.dev/docs/getting-started/): publish a
preview release, confirm a rebuilt device receives it, and test a rollback.
One additional check is specific to a migration from CodePush: confirm the
rebuilt binary's native project no longer contains CodePush's deployment key
or native configuration.
