Examples

RN2KMP demos

Run a minimal RN2KMP setup or a Pokédex that switches between React Native and Compose screens while keeping Expo Router in charge.

On this page

Both demos need an Expo development build and the native tools for your platform. Use a JDK and the Android SDK for Android, or macOS with Xcode and CocoaPods for iOS. See the requirements.

Installation demo#

The shared Kotlin Multiplatform module exports a sayHello function and an App composable. The Expo app imports both from the generated npm package.

tsx
import { StyleSheet } from "react-native";
import { App, sayHello } from "react-native-shared";

export default function Index() {
  console.log(sayHello("World")); // Call a function from KMP

  return (
    <App style={styles.container}/> // Render a component from KMP
  );
}

const styles = StyleSheet.create({
  container: { flex: 1, alignItems: "center", justifyContent: "center" },
});

The app logs Hello, World! and shows the Compose component inside its React Native screen.

Run the installation demo#

bash
git clone https://github.com/rn2kmp/demo
cd demo/kotlin-multiplatform-app
./gradlew :shared:generateReactNativeBindings

cd ../react-native-app
npm install
npm run ios       # or: npm run android

Installation demo repository · Plugin version used by the demo

Migration demo#

The Pokédex uses Expo Router for its list, detail and settings routes. Open Settings from the list header to choose the UI and HTTP client independently for the List screen and Detail screen. The app remembers your choices.

Screen UI HTTP client Where the request runs
React Native Axios In JavaScript through pokenode-ts.
React Native Ktor In Kotlin through an RN2KMP-exported function.
Compose Multiplatform Ktor only In Kotlin, from the Compose screen's data layer. The app disables Axios for that screen.

Try keeping the list in React Native and switching the detail to KMP (Compose). Open a Pokémon, go back, then switch the list to Compose too. A tap on the Compose list emits onPokemonClick(id), and Expo Router still opens /pokemon/[id]. Switching either screen back to React Native keeps the same routes. The navigation guide explains this boundary.

Run the Pokédex#

bash
git clone https://github.com/rn2kmp/demo-pokedex
cd demo-pokedex/kotlin-multiplatform-app
./gradlew :shared:generateReactNativeBindings

cd ../react-native-app
npm install
npm run ios       # or: npm run android

The repository also includes a standalone Compose app with Navigation 3 so you can run the list and detail without the React Native shell. Its README has the separate setup steps.

Pokédex repository · Plugin version used by the Pokédex

Bring it to your app#

Add RN2KMP to your app or choose the first screen to migrate.