Installation
Installation guide for Stallion in 5 easy steps.
Setting up Stallion is straight forward, just install the CLI and SDK and start using. Stallion requires react-native version 0.69 or higher for optimal performance.
SDK Installation
To get started, install the SDK using npm or yarn.
Step 1: Install the Stallion SDK and CLI
Begin by installing SDK in your react-native project:
npm i react-native-stallion
or if you are using yarn then
yarn add react-native-stallion
for steps to install the CLI checkout CLI Installation Docs
Step 2: Native Installation
After installing the SDK, you need to install pods for iOS and gradle sync android project:
npx pod-install
Step 3: Add Stallion bundle support in Android and iOS projects
- Android - Inside
MainApplication.java
, override and implementgetJSBundleFile
method :
// ...other imports
import com.stallion.Stallion;
public class MainApplication extends Application implements ReactApplication {
// ...rest of the class
@Override
protected String getJSBundleFile() {
return Stallion.getJSBundleFile(getApplicationContext());
}
}
- iOS - Inside
ios/AppDelegate.mm
file editsourceURLForBridge
method
// ...other imports
#import <react-native-stallion/StallionModule.h>
@implementation AppDelegate
// ...other implemetations
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
#else
return [StallionModule getBundleURL];
#endif
}
Step 4: Add ProjectId & AppToken in native
-
Get projectID from Stallion Dashboard : On project info page, copy project id.
-
Generate App Token : On project settings page click on
Generate App Token
to create a new app token
Add StallionProjectId
& StallionAppToken
as shown below -
-
iOS: Add the copied App Token and projectId to
info.plist
-
android: Add the copied App Token and projectId to
strings.xml
Step 5: Import and add Stallion as HOC in App.js
- Import
withStallion
HOCimport { withStallion } from 'react-native-stallion';
- Wrap root component (generally App.tsx or App.js) with HOC
export default withStallion(App)
- Add a custom entry point to Stallion Modal UI
Choose any custom entry point in your app. Import
useStallionModal
hook
Trigger showModal from your custom component.
Tip:
The Stallion SDK entry point is determined by you and is intended only for internal users. Each app can hide this entry point behind more complex UI elements or a feature flag.
import { useStallionModal } from "react-native-stallion";
//This is an example, you can call setShowModal from any custom component
const MyCustomPageComponent: React.FC = () => {
const { showModal } = useStallionModal();
return (
<>
// Other page level components
<Button title="Open Stallion" onPress={showModal} />
</>
);
};
- Finally
Stallion SDK modal should open by using the custom entry point from above step. All your builds should be available in a list to download and install.
With this setup, you’ll have installed Stallion. I next section we will see how to use Stallion to deploy bundles and get realtime updates.