In the summer of 2025, the ControlResell API was running on two backends. Every request still arrived at our old Express server. Some went straight through to Ktor. The rest were handled by Express as before. From the client’s point of view, it was the same API.
That setup gave us time to move the backend in stages. When we started looking at moving our React Native app to Kotlin Multiplatform, we wanted to keep shipping in the same way, one piece at a time.
How we moved the backend
When I joined ControlResell, the backend was written in TypeScript. Our build and release setup let code with type errors reach production, and I was spending time chasing problems I wanted the build to catch. I’d already built backends with Kotlin and Ktor, so we started using them for new services. Once we had both stacks running, we decided to bring the existing API over too.
Tightening the TypeScript checks was an option, and moving to Ktor made sense for us given the experience and code we already had. The trade-offs behind that decision deserve an article of their own. Once we’d made our choice, we still had to find a way to move the API while people were using it.
The migration proxy lived in the Express app itself. We kept a list of the paths we’d moved. A request matching the list was forwarded to Ktor before it reached the Express router. Everything else went through the existing handlers. We could move a group of routes without changing the URLs our clients used.
During the migration
Client → Express → Ktor for migrated paths
→ Express handlers for the rest
After the migration
Client → Ktor
Once Ktor handled the whole API, the Express entry point had done its job. We removed it along with the Node.js backend. The backend felt noticeably more stable to us after the transition, and we had one stack to maintain.
Doing the same thing inside a mobile app
By then, we already had Kotlin API models, DTOs and a client that we could use from a Kotlin Multiplatform module. On the mobile side, we were also dealing with some of the same type-safety issues we’d run into on the backend, alongside parts of our React architecture that we found increasingly hard to work with. Having Kotlin code we could reuse made KMP a practical choice for us. The trade-offs between React Native and KMP deserve an article of their own.
For mobile, we wanted React Native to play a similar role during the handover. It would keep the app and its navigation running while we moved individual screens to Compose Multiplatform. Once the Kotlin app could take over navigation and the rest of the app, we could remove the React Native shell.
That’s where the backend analogy starts to break down. An HTTP proxy can pass a request to another process. A Compose screen has to render inside the existing app, receive its inputs and send actions back to the React Native router. You have to wire that up on both platforms.
I looked for an existing tool and didn’t find much that covered this setup. I figured I’d wire it up by hand. I remember spending about two days getting the initial setup working, which was longer than I’d expected. On Android we embedded a ComposeView. On iOS we hosted a Compose view controller inside a native React Native view. Expo added a build problem of its own. Its prebuild regenerates the native projects, so we wrote config plugins to reapply our changes and make sure the Kotlin framework was linked before CocoaPods installed the dependencies.
What we kept doing by hand
The orders screen was one of the first places we tried it. Item history made the boundary especially clear. React Navigation opened the route with an item ID. A React wrapper passed that ID down to the Compose screen. When Compose needed to open another screen, it sent an event back up, and the React Native router acted on it.
By the time we’d wired up three or four screens, the same work was becoming familiar. Each screen had its own UI and behaviour, but the platform glue followed a pattern. We were defining how values and events crossed the boundary, wiring them up on Android and iOS, and making them available to React Native.
The question came naturally after a few rounds of that. Could we describe what a Kotlin screen exposes and generate the integration from that description?
Making the next screen easier to move
Take item history again. The screen needed an item ID and a way to ask the app to navigate. We’d wired both across by hand. If we could describe those inputs and events in Kotlin and generate the glue from that declaration, we could spend more of the next migration on the screen itself.
That’s where RN2KMP came from. Mark a composable with @ReactNativeComponent and the Gradle plugin generates a React Native package with a typed TypeScript API and the native bindings for Android and iOS. The React route imports the component and still decides what to do when it receives an event. The same setup also lets React Native call an annotated Kotlin function, so the first piece you move could be smaller than a screen.
Here’s a minimal version of the demo’s App composable and sayHello function.
@ReactNativeComponent
@Composable
fun App() {
Text("Hello from Compose")
}
@ReactNativeFunction
fun sayHello(name: String): String = "Hello, $name!"
In React Native, the screen imports both from the generated package.
import { App, sayHello } from "react-native-shared";
export default function Screen() {
console.log(sayHello("World"));
return <App style={{ flex: 1 }} />;
}
What I wanted from the start was the freedom we’d had with the backend. When one set of routes was ready, we could move it and leave the rest serving traffic. With the mobile app, that means taking one screen, keeping its route and seeing how the Compose version behaves alongside the screens we already ship. Each move brings the Kotlin app closer to being ready to take over.
If you’re at the point where we were before that first screen, you can try the demo or pick a screen to migrate with the guide on RN2KMP.
Top comments (0)