Getting Started
This guide will walk you through setting up SilverOTA in your React Native project.
Prerequisites
- Node.js 18 or higher
- React Native project (bare or Expo)
- A SilverOTA account (sign up here)
Installation
1. Install the CLI
Install the SilverOTA CLI as a development dependency:
npm install -D @silverbullet-ota/cliyarn add -D @silverbullet-ota/clipnpm add -D @silverbullet-ota/cli2. Login to Your Account
Authenticate with your SilverOTA account:
npx silverbullet-ota loginThis will:
- Request a device authorization code
- Open your browser for confirmation
- Store your authentication token securely in your system keyring
3. Initialize Your Project
Run the interactive initialization wizard:
npx silverbullet-ota project initThe wizard will guide you through:
Step 1: Select Build Plugin
- Choose Bare for React Native CLI projects
- Choose Expo for Expo-managed workflows
Step 2: Install Required Packages The CLI will automatically install:
@silverbullet-ota/react-native- The React Native SDK@silverbullet-ota/bareor@silverbullet-ota/expo- Build plugin for your workflow
Step 3: Select Organization
- Choose which organization this project belongs to
- If you only have one organization, it will be auto-selected
Step 4: Select or Create Project
- Choose an existing project or create a new one
- Projects group your deployments and manage versioning
Step 5: Configure API Keys
- If no production API key exists, one will be created automatically
- If multiple keys exist, you'll be prompted to select one
- API keys are channel-specific and used for authentication
Step 6: Configuration File Created The wizard creates an ota.config.ts file:
import { configureOTA } from 'silverbullet-ota';
import { bare } from '@silverbullet-ota/bare';
export default configureOTA({
projectId: 'your-project-id',
apiKey: 'pk_your_api_key',
build: bare({ enableHermes: true }),
});Step 7: Package Scripts Added The following scripts are added to your package.json:
{
"scripts": {
"silverbullet:deploy:android": "silverbullet-ota deploy --platform android",
"silverbullet:deploy:ios": "silverbullet-ota deploy --platform ios"
}
}Step 8: .gitignore Updated The .silverbullet-ota output directory is added to .gitignore
4. Configure Your React Native App
Add the SilverOTA SDK to your app's entry point (typically App.tsx or index.js):
import { SilverbulletOta } from '@silverbullet-ota/react-native';
function App() {
return (
<YourAppComponent />
);
}
export default SilverbulletOta.wrap({})(App);5. Set Your Channel (Optional)
By default, your app is configured to use the production channel. You only need to change this if you want to use a different channel (e.g., staging, beta, or a custom channel).
TIP
Skip this step if you want to use the production channel. It's already configured for you!
To switch to a different channel, run:
npx silverbullet-ota channel set <channel-name>For example, to use the staging channel:
npx silverbullet-ota channel set stagingThis command updates your native configuration files:
- iOS: Updates
Info.plistwithSILVERBULLET_OTA_CHANNEL - Android: Updates
strings.xmlwithsilverbullet_ota_channel
WARNING
After changing channels, you must rebuild your native app! Channels are configured at build time and cannot be changed via OTA updates.
6. Deploy Your First Update
Deploy an update to your users using the convenient npm scripts:
npm run silverbullet:deploy:iosnpm run silverbullet:deploy:androidOr use the CLI directly with more options:
npx silverbullet-ota deploy \
--platform ios \
--target-app-version 1.0.0 \
--channel production \
--message "Initial OTA deployment"Verification
To verify everything is working:
- Build your app with the native code changes (channel configuration)
- Run your app on a simulator or device
- Make a code change (e.g., update some text)
- Deploy the update using the deploy command
- Restart your app - you should see the update applied
Next Steps
Now that you have SilverOTA set up, explore these topics:
- Learn about CLI commands - Understand all available commands
- Explore the SDK API - Customize update behavior
- Set up staging workflows - Test before production
- Understand channels - Manage multiple environments