Setup
Get CodePush running with Codemagic and React Native
This section prepares a project to use CodePush with Codemagic. After completing these steps you will have:
- a CodePush project created on the Codemagic server
- the CLI installed and authenticated
- a React Native app configured to receive OTA updates
Codemagic hosts the CodePush server and developers interact with it using access tokens and the CodePush CLI. If you want to learn about how OTA updates work, check out the concepts page.
These instructions are for React Native New Architecture projects. If your app is already configured, skip to setting up deployment keys and CI sections to verify configuration.
The same Codemagic server can be used for all of your apps.
Install and configure the CLI
Install the CodePush CLI globally:
npm install -g @codemagic/code-push-cliVerify the installation:
code-push --versionThis command prints the installed CLI version. If the installation was successful, you will see a version number (e.g., x.x.x). If the command is not found, it usually means the CLI was not installed correctly.
Get an access token
The CodePush CLI authenticates using access tokens provided by the Codemagic team. Request a token here.
To log in from the CLI:
code-push login "https://codepush.pro/" --access-key $ACCESS_TOKENThis command authenticates the CLI directly using the provided access token. Once authenticated, the CLI can create apps, manage deployments, and publish updates.
Create a CodePush project
Each mobile application using CodePush must be registered on the server. This step creates a record on the CodePush server that your app will connect to for receiving updates.
In most cases, you should create separate apps for each platform, for example:
- MyApp-Android
- MyApp-iOS
React Native bundles differ between platforms, so separating them ensures that each app receives the correct update package and avoids compatibility issues.
To create an Android app using the CLI:
code-push app add MyApp-AndroidFor iOS:
code-push app add MyApp-iOSYou can use any naming convention, but including the platform in the name is recommended for clarity when managing multiple apps.
When an app is created, CodePush automatically creates two deployments:
- Staging
- Production
These deployments act as separate release channels, allowing you to control which users receive which updates.
- Staging → typically used for testing updates internally
- Production → used for releasing updates to end users
You can create additional deployments if needed (e.g., QA, Beta), depending on your workflow by running code-push deployment add <appName> <deploymentName>. It is possible to rename existing deployments through code-push deployment rename <appName> <deploymentName> <newDeploymentName> and delete via code-push deployment rm <appName> <deploymentName>
Add CodePush to a React Native app
After configuring the server and CLI, the next step is integrating the CodePush client SDK into your React Native application. This allows your app to receive over-the-air (OTA) updates without going through the app store.
- Install the React Native CodePush package:
# Using npm
npm install @code-push-next/react-native-code-push
# Using yarn
yarn add @code-push-next/react-native-code-pushThe SDK handles checking for updates, downloading new bundles, and applying updates when the app restarts.
- Configure Deployment Keys
Each CodePush deployment has a deployment key that tells the app which deployment to check for updates.
List deployments and keys:
code-push deployment list <app_name> -kRecommended usage:
- Development builds → Staging deployment key
- Production builds → Production deployment key
This ensures test updates do not reach production users. Deployment keys are typically injected via environment variables or set in platform configuration files.
- Configure Server URL and Deployment Keys in Native Projects
To connect your React Native app to the CodePush server, you must configure the server URL and the deployment key in your native project files. These values tell the app which server to check for updates and which deployment channel to use.
Server URL for Codemagic hosted service:
https://codepush.pro/iOS (Info.plist) example:
<key>CodePushServerURL</key>
<string>https://codepush.pro/</string>
<key>CodePushDeploymentKey</key>
<string>YOUR_DEPLOYMENT_KEY</string>📒 Notes:
- Replace YOUR_DEPLOYMENT_KEY with the key for Staging (development builds) or Production (release builds).
- These keys can also be injected dynamically using build scripts or environment variables to avoid hardcoding sensitive information.
- Ensures the app connects to the correct deployment when it starts.
Android (strings.xml) example:
<string moduleConfig="true" name="CodePushServerUrl">https://codepush.pro/</string>
<string moduleConfig="true" name="CodePushDeploymentKey">YOUR_DEPLOYMENT_KEY</string>📒 Notes:
- Same as iOS, use the correct deployment key for your build type.
- If you have multiple build variants (e.g., debug, release), configure keys separately for each variant to prevent test updates from reaching production users.
- Wrap Your Root Component with CodePush
Integrate CodePush by wrapping your app’s root component:
import codePush from '@code-push-next/react-native-code-push';
function App() {
// Your app code here
}
export default codePush(App);This enables the SDK to automatically check for updates on app start (or based on your chosen update strategy).
- Run a test OTA release
To verify that CodePush is working end-to-end, you can publish a quick test release:
code-push release-react <app_name> <platform_ios_or_android>This single command:
- Bundles your React Native JavaScript code
- Uploads it to the CodePush server
- Releases it to the default deployment (usually Staging, if another deployment channel is needed, you can manage it by adding
-d <deployment_name>to the command above)
For the full release workflow, see Releasing updates.
✅ Best Practices
- Use Environment Variables – Avoid hardcoding deployment keys.
- Separate Staging and Production Keys – Always validate updates in Staging before promoting to Production.
- Confirm Connectivity – After configuration, make sure the app can fetch updates from the server by testing a Staging release.
Properly configuring the server URL and deployment keys ensures that CodePush can deliver OTA updates reliably and safely for each platform.
Next steps
After completing setup, use the following sections to continue:
- Releasing updates - publish your first OTA release
- CLI quick reference - copy-paste commands for auth, releases, and rollouts
- CI integration - automate releases in CI/CD
- Production control - rollouts, rollbacks, and version targeting
- Security and access - authentication and signing
- Debugging and common issues - troubleshooting
- Advanced: sync options - customize
sync(), dialogs, progress, and restart behavior