CLI Reference
The AppSpacer CLI (appspacer) is a command-line tool for pushing OTA updates to your React Native apps, managing deployments, and configuring native project files — all from your terminal.
Installation
Install the CLI globally via npm:
npm install -g appspacer-cliOr run commands on-demand with npx:
npx appspacer <command>After installation, the appspacer binary is available system-wide.
Configuration
The CLI stores configuration in ~/.appspacer/config.json. This file is created automatically when you first run appspacer login.
| Field | Description | Default |
|---|---|---|
apiUrl | Your AppSpacer backend URL | https://api.appspacer.com/api |
accessToken | Personal Access Token (PAT) | null |
You can override the API URL at login time:
appspacer login --api-url https://your-backend.example.com/apiCommands
appspacer login
Authenticate with the AppSpacer backend using a Personal Access Token (PAT).
# Interactive — prompts for token
appspacer login
# Non-interactive — pass token directly
appspacer login -t pat_d614b9fcc6d5f5181c04b729e09f7b687ae71e90
# Custom backend URL
appspacer login -t pat_xxxx --api-url https://your-backend.example.com/apiOptions:
| Flag | Description |
|---|---|
-t, --token <token> | Personal Access Token (must start with pat_) |
--api-url <url> | Override the API base URL |
Tokens are generated from the AppSpacer dashboard under Settings → Tokens.
On success, the CLI verifies your token and displays your identity:
✓ Logged in as Jane Doe (jane@company.com)appspacer whoami
Display the currently authenticated user.
appspacer whoami✓ Logged in as Jane Doe (jane@company.com)appspacer setup
Auto-configure your React Native project’s native files for OTA updates. This is the recommended way to set up AppSpacer — it handles all native code injection automatically.
# Run from your React Native project root
appspacer setupWhat it does:
- Verifies
react-native-appspaceris installed innode_modules - Detects your Android project structure and React Native architecture
- Injects the correct bundle resolver into
MainApplication.kt - Configures
AppDelegate.mmorAppDelegate.swiftfor iOS - Creates backup files (
.appspacer.bak) before making changes
Options:
| Flag | Description | Default |
|---|---|---|
--android-only | Only configure Android | — |
--ios-only | Only configure iOS | — |
--project-dir <dir> | Path to your RN project root | . |
--dry-run | Preview changes without writing files | — |
Examples:
# Full setup — Android + iOS
appspacer setup
# Preview what would change
appspacer setup --dry-run
# Only configure Android
appspacer setup --android-only
# Project in a different directory
appspacer setup --project-dir ./my-react-native-appArchitecture detection:
The CLI automatically detects which React Native architecture pattern your project uses:
| Architecture | RN Version | Detection |
|---|---|---|
| New Architecture (ReactHostDelegate) | 0.73+ | ReactHostDelegate, ReactHostImpl, DefaultReactHost patterns |
| Traditional (ReactNativeHost) | < 0.73 | ReactNativeHost, getJSBundleFile patterns |
The correct injection code is chosen automatically based on the detected architecture.
appspacer setup:undo
Remove all AppSpacer injections from your native files. Restores original code by removing content between // APPSPACER_START and // APPSPACER_END markers.
appspacer setup:undoOptions:
| Flag | Description | Default |
|---|---|---|
--project-dir <dir> | Root directory of the React Native project | . |
appspacer release
Upload a pre-built JS bundle zip and create an OTA release. Use this when you have a manually built bundle file.
appspacer release \
-a my-app-android \
-d Staging \
-p android \
-f ./release.zip \
-t "1.0.0" \
--description "Fixed login crash" \
--mandatoryOptions:
| Flag | Description | Required |
|---|---|---|
-a, --app <appIdOrName> | App ID (UUID) or app name | ✅ |
-d, --deployment <name> | Deployment name (e.g. Staging, Production) | ✅ |
-p, --platform <os> | Target platform (android or ios) | ✅ |
-f, --file <path> | Path to the bundle file (.zip or .bundle) | ✅ |
-t, --target-version <version> | Target app version or semver range (e.g. 1.0.0, ^1.0.0) | ✅ |
--description <text> | Release description | ❌ |
--mandatory | Mark update as mandatory | ❌ |
Upload flow:
- Requests a presigned upload URL from the server
- Streams the file to cloud storage with a progress bar
- Creates a release record linking the uploaded file to the deployment
Output on success:
✓ Release created successfully!
Platform: android
Deployment: Staging
Target: 1.0.0
Bundle: https://storage.example.com/bundles/update.zip
Size: 245.3 KB
Release ID: 8f3a2c1e-...appspacer release-react-native
The recommended release command for React Native projects. Automatically bundles your app, packages it into a zip, computes the SHA-256 hash, uploads, and creates the release — all in one step.
appspacer release-react-native <platform> [options]Arguments:
| Argument | Description |
|---|---|
<platform> | Target platform: android or ios |
Options:
| Flag | Description | Required |
|---|---|---|
-a, --app <appIdOrName> | App ID or name | ✅ |
-d, --deployment <name> | Deployment name (e.g. Staging, Production) | ✅ |
-t, --target-version <version> | Target app version (e.g. 1.0.0) | ✅ |
--description <text> | Release description | ❌ |
--mandatory | Mark update as mandatory | ❌ |
--include-assets | Include assets in the bundle (increases size) | ❌ |
Examples:
# Push a staging update for Android
appspacer release-react-native android \
-a my-app-android \
-d Staging \
-t 1.0.0 \
--description "Bug fix for checkout flow"
# Push a mandatory production update for iOS
appspacer release-react-native ios \
-a my-app-ios \
-d Production \
-t 1.2.0 \
--description "Critical security patch" \
--mandatory
# Include assets (images, fonts, etc.)
appspacer release-react-native android \
-a my-app-android \
-d Staging \
-t 1.0.0 \
--include-assetsAutomated pipeline:
- Bundle — Runs
npx react-native bundlefor the target platform - Package — Zips the build output into
update.zip - Hash — Computes SHA-256 hash for integrity verification
- Upload — Streams the zip to cloud storage with progress bar
- Release — Creates a release record on the server
- Cleanup — Removes temporary build artifacts
appspacer deployments
List all deployments (e.g. Staging, Production) for an app, along with their deployment keys.
appspacer deployments -a my-app-androidOptions:
| Flag | Description | Required |
|---|---|---|
-a, --app <appIdOrName> | App ID or name | ✅ |
Output:
Deployments (2):
Staging
Key: sk_abc123...
Production
Key: sk_def456...Use these deployment keys in your SDK configuration (deploymentKey parameter).
appspacer rollback
Roll back the latest release for a specific deployment and platform. This disables the most recent release and re-activates the previous one.
appspacer rollback \
-a my-app-android \
-d Production \
-p androidOptions:
| Flag | Description | Required |
|---|---|---|
-a, --app <appIdOrName> | App ID or name | ✅ |
-d, --deployment <name> | Deployment name | ✅ |
-p, --platform <os> | Target platform (android or ios) | ✅ |
Output:
✓ Rollback successful!
Disabled Release: v5 (v5)
Now Active: v4 (v4)Common Workflows
First Time Setup
# 1. Install the CLI
npm install -g appspacer-cli
# 2. Authenticate with a Personal Access Token
appspacer login -t pat_your_token_here
# 3. Install the SDK in your React Native project
cd my-react-native-app
npm install react-native-appspacer
# 4. Auto-configure native files
appspacer setup
# 5. Rebuild your app
npx react-native run-android
npx react-native run-iosPublishing an Update
# Push to staging first
appspacer release-react-native android \
-a my-app \
-d Staging \
-t 1.0.0 \
--description "New feature: dark mode"
# Test on staging, then promote to production
appspacer release-react-native android \
-a my-app \
-d Production \
-t 1.0.0 \
--description "New feature: dark mode"Rolling Back a Bad Release
# Something went wrong — roll back immediately
appspacer rollback -a my-app -d Production -p android
# Verify the rollback
appspacer deployments -a my-appExit Codes
| Code | Meaning |
|---|---|
0 | Success |
1 | Error — authentication failure, file not found, server error, etc. |
Troubleshooting
| Issue | Cause | Solution |
|---|---|---|
Not logged in | Token is missing or expired | Run appspacer login again |
File not found | Bundle path is incorrect | Verify the -f flag path exists |
FORBIDDEN error | You’re not a member of the app’s org | Contact your team admin |
Upload failed | Network or storage issue | Check connectivity and retry |
Bundling failed | React Native bundle error | Fix JS errors and retry |
Already configured | Setup was run before | Safe to re-run — it replaces the previous injection |