Setup React Native Mini-app
Follow the steps below to set up a React Native mini-app
#
Update the JS entry pointPlease change your appKey
when registering JS entry point to RNMain
.
#
Handle the initial propsWhen starting a mini-app, Terra will pass some properties to your mini-app via the props
of the root component of your mini-app (It's usually the <App />
component). The initial props may include (based on your mini-app's business):
- Auth data: if your mini-app uses Exchange Token Flow, an
terraIdToken
will be passed viaprops
. - Configs for starting the mini-app from the host app: such as language, host app's identity (these are defined by you - the mini-app team). Let call them as
custom
properties.
In the root component of your app, use the code below to get the initial props:
#
Connect with Javascript bridgeThis step is required if you need to access Terra
features (currently only run in native code). Please refer Javascript bridge for more information.
#
Publish the mini-appWe provide a command-line tool, called terra-rn
, for publishing a React Native mini-app to the Teko package. The mini-apps will be downloaded and used in the host app when integrating the mini-apps into the host app.
To publish a mini-app we need to do the steps bellow:
#
Get your mini-app's IDContact the Terra team to get the id of your mini-app. We need two IDs for both Android and iOS. Normally, both IDs are the same.
#
Add config to the app.json file- Add config for Terra to the
app.json
file in the root folder of the mini-app.
For example:
#
Install and log in to the cli toolInstall the
terra-rn
cli tool (Cooming soon, this tool is under Beta testing now)Log in to the cli tool. Please contact the Terra team to get account information for logging into cli tool.
#
Publish the mini-appFor Android version:
For iOS version:
#
Provide react-native's version and dependencies that use native modulesYour mini-apps may use some dependencies that use native modules, such as react-native-gesture-handler
, react-native-svg
,... You need to provide us information about these dependencies (and some installation instructions if you feel necessary). This information will be used during the integration of your mini app with a host app.