Open Bulbasaur in our Pokédex and you get a React Native detail screen. Go back, open Settings, and switch only the detail screen to Compose Multiplatform. Tap Bulbasaur again. The header still says #1, the list still runs in React Native, and the same back button takes you to the same place.
In the previous article, I wrote about moving our backend from Express to Ktor one route at a time. That story raised a practical question about doing the same thing on mobile. If React Native and Compose are both in the app, who decides what opens when you tap something, and where you land when you go back? What a backend proxy taught us about migrating from React Native to Kotlin Multiplatform
In the Pokédex, Expo Router owns navigation throughout the migration. The existing route chooses which UI to render. Here’s what switching an actual screen looks like.
The route stays where it is
The detail route lives in app/pokemon/[id].tsx. It reads the route parameter, sets the header, and chooses which component to render. In the Compose branch, PokemonDetailScreen is imported from the package generated by RN2KMP. From the route’s point of view, it’s a React component that takes a pokemonId prop. Pokédex detail route
import { PokemonDetailScreen } from "react-native-shared";
import { PokemonDetailRn } from "@/components/PokemonDetailRn";
import { useSettings } from "@/settings/settings";
export default function DetailRoute() {
const id = Number(useLocalSearchParams<{ id: string }>().id);
const { detail } = useSettings().settings;
return (
<>
<Stack.Screen options={{ title: `#${id}` }} />
<BelowHeader>
{detail.owner === "kmp" ? (
<PokemonDetailScreen style={{ flex: 1 }} pokemonId={id} />
) : (
<PokemonDetailRn id={id} http={detail.http} />
)}
</BelowHeader>
</>
);
}
Expo Router still opens /pokemon/1, owns the transition, and pops the detail when you go back. In the Compose branch, Fabric mounts the native view that hosts the composable. The visit to /pokemon/1 belongs to the router. Rendering the contents of that visit belongs to the selected component. Expo Router navigation · Navigation and Fabric guide
A Compose screen can ask to open the next route
Now switch the list to Compose as well. A tap inside that list runs a Kotlin callback, onPokemonClick(id). RN2KMP exposes it as an event on the generated React component. The React Native route passes the same open handler to either list implementation, so the detail opens the same way for both. Kotlin exports · Pokédex list route
import { useRouter } from "expo-router";
import { PokemonListScreen } from "react-native-shared";
import { PokemonListRn } from "@/components/PokemonListRn";
import { useSettings } from "@/settings/settings";
export default function ListRoute() {
const router = useRouter();
const { list } = useSettings().settings;
const open = (id: number) => router.push({ pathname: "/pokemon/[id]", params: { id } });
// The key remounts the screen when the setting changes.
return (
<BelowHeader>
{list.owner === "kmp" ? (
<PokemonListScreen key="kmp" style={{ flex: 1 }} onPokemonClick={open} />
) : (
<PokemonListRn key={list.http} http={list.http} onPokemonClick={open} />
)}
</BelowHeader>
);
}
I’d use the same boundary for an app-level action such as closing a detail screen or opening a related item. Give the Compose screen a callback that describes the action. Let the route decide whether it means pushing a screen, dismissing a modal, or going back. A wizard can still manage its own steps inside a route. The app-level back stack stays with React Native while the two stacks coexist.
Keep a way back while you roll out the screen
The Pokédex uses a local setting so you can see both versions. In an existing app, put the same choice behind your usual rollout flag. Both implementations need to be in the installed binary for the flag to switch between them. They also need to agree on the route’s inputs and any data either version writes. Pick what the app should show when it can’t read the flag or only has a cached value.
For a first screen, I’d run three checks on Android and iOS.
- Enter through the existing flow. Open the detail from the list, go back, then reopen it. Check the header, parameters, and the back behavior that users already expect on that platform.
- Try the route’s existing deep links. Open a detail from a cold start. A direct link may leave the detail without a list behind it. Decide where Back should take the user in that case, and check both implementations.
- Switch back on the same installed build. Open the Compose screen, exercise any real writes, and switch back to React Native. Confirm that the original screen can still read the state and that the route still opens as before.
When Kotlin takes over
We keep the global router in React Native while the app still relies on the React Native shell. Once the Kotlin app can handle the routes, deep links, and upgrade path for existing users, it can take over navigation. The same Pokédex repo includes a standalone Kotlin app that runs the list and detail with Navigation 3. It’s a separate build that shows what the destination can look like. Standalone Pokédex navigation
If you’re choosing a first screen, take a route with one clear way in and one clear way back. Keep the route where it is, give it a Compose implementation, and prove that you can switch between the two. Try the RN2KMP Pokédex demo
Top comments (0)