Docs

Installation

Apply the RN2KMP Gradle plugin, generate the bindings and install the local package in React Native.

On this page

Check the project requirements first. These commands use the shared module and react-native-kmp package names from the sample configuration.

Apply the Gradle plugin#

In the KMP root settings.gradle.kts, make mavenCentral() available in both pluginManagement.repositories and dependencyResolutionManagement.repositories.

Apply the published RN2KMP Gradle plugin on Maven Central at the top of kmp/shared/build.gradle.kts. If the version is unavailable in the snippet, replace REPLACE_WITH_VERSION with a release from Maven Central.

kotlin
plugins {
    alias(libs.plugins.kotlinMultiplatform)
    alias(libs.plugins.androidMultiplatformLibrary)
    alias(libs.plugins.composeMultiplatform)
    alias(libs.plugins.composeCompiler)
    id("dev.rn2kmp") version "0.1.1"
}

Set the generated package location and add your first Kotlin exports.

Generate and install the package#

From kmp/:

bash
./gradlew :shared:generateReactNativeBindings

Run it once before installing the package, and again whenever the exported Kotlin API changes. Changing only the implementation needs a rebuild of the app, not a new generation. The generated folder is never committed: it has its own .gitignore, so a fresh clone needs this step before npm install.

From react-native/:

bash
npm install ./packages/react-native-kmp

For Expo Android, check the host Kotlin version before building the development client.