React Native

Learn how to add Adapty React Native SDK to your project

❗️

Read Checklist before releasing your app

Be sure to carefully read Release Checklist when releasing your app. It's critical to make things right from the first attempt!

Currently, React Native offers two ways of development flows: Expo and "pure". Adapty can work with both. Please, refer to the only one section below that matches your setup.

Expo (managed)

You can avoid local builds with EAS, configuration may vary depending on your setup, but here you can find the most common and simple setup.

0.1. If you don't have EAS CLI yet, install it with following command

npm install -g eas-cli

0.2. Then in the root of your project install dev client to make a development build

expo install expo-dev-client
  1. Run the installation command:
expo install react-native-adapty
  1. iOS: Make an iOS build with EAS CLI. This command may prompt you for an additional info. You can refer to official documentation to find out more.
eas build --profile development --platform ios
  1. Android: Make an Android with EAS CLI. This command may prompt you for an additional info. You can refer to official documentation to find out more.
eas build --profile development --platform android
  1. Start a development server with the following command.
expo start --dev-client

This should result into the working app with react-native-adapty.

🚧

Failed to start (Invariant Violation: Native module cannot be null)

if you scan QR code from CLI dev client it might lead you to this error. To resolve it you can try the following:
On your device open EAS built app (it should provide some Expo screen) and manually insert URL that Expo provides (screenshot below). You can unescape special characters in URL with JS function unescape(“string”), which should result into something like http://192.168.1.35:8081

Pure React Native

If you prefer a pure workflow. refer to following instructions:

  1. In your project run the installation command:
yarn add react-native-adapty
  1. iOS: Install required pods:
pod install --project-directory=ios
  1. Android: Update /android/build.gradle file. Make sure there is a kotlin-gradle-plugin:1.4.0 dependency or newer:
...
buildscript {
  ...
  dependencies {
    ...
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.0"
  }
}
...
  1. Android: Update android/app/build.gradle file. Make sure multiDex is enabled:
...
android {
  ...
  defaultConfig {
    ...
    multiDexEnabled true
  }
}

What’s Next