Skip to content

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:

bash
npm install -D @silverbullet-ota/cli
bash
yarn add -D @silverbullet-ota/cli
bash
pnpm add -D @silverbullet-ota/cli

2. Login to Your Account

Authenticate with your SilverOTA account:

bash
npx silverbullet-ota login

This will:

  1. Request a device authorization code
  2. Open your browser for confirmation
  3. Store your authentication token securely in your system keyring

3. Initialize Your Project

Run the interactive initialization wizard:

bash
npx silverbullet-ota project init

The 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/bare or @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:

typescript
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:

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):

tsx
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:

bash
npx silverbullet-ota channel set <channel-name>

For example, to use the staging channel:

bash
npx silverbullet-ota channel set staging

This command updates your native configuration files:

  • iOS: Updates Info.plist with SILVERBULLET_OTA_CHANNEL
  • Android: Updates strings.xml with silverbullet_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:

bash
npm run silverbullet:deploy:ios
bash
npm run silverbullet:deploy:android

Or use the CLI directly with more options:

bash
npx silverbullet-ota deploy \
  --platform ios \
  --target-app-version 1.0.0 \
  --channel production \
  --message "Initial OTA deployment"

Verification

To verify everything is working:

  1. Build your app with the native code changes (channel configuration)
  2. Run your app on a simulator or device
  3. Make a code change (e.g., update some text)
  4. Deploy the update using the deploy command
  5. Restart your app - you should see the update applied

Next Steps

Now that you have SilverOTA set up, explore these topics: