BlogReact Native
Why I build React Native apps with TypeScript
How TypeScript makes a cross-platform codebase safer, when React Native is the right choice, and when I reach for Swift instead.
I’ve worked in React Native for over three years alongside native iOS, shipping apps like BLOK Pass and Live Building Systems to both the App Store and Google Play, and training client teams along the way. These days I start every React Native project in TypeScript. Here’s why, and how I set it up.
Types catch bugs before your users do
A React Native codebase passes a lot of data around: API responses, component props, navigation parameters, app state. In plain JavaScript, a typo or a missing field shows up as a crash on someone’s phone. With TypeScript, the editor flags it while you type.
type Ride = {
id: string;
driver: string;
seats: number;
};
type RideRowProps = {
ride: Ride;
onRequest: (id: Ride["id"]) => void;
};
export function RideRow({ ride, onRequest }: RideRowProps) {
return (
<Pressable onPress={() => onRequest(ride.id)}>
<Text>{ride.driver}</Text>
<Text>{ride.seats} seats</Text>
</Pressable>
);
}
New React Native projects use TypeScript by default, so there’s little reason to start without it. I also turn on "strict": true in tsconfig.json from day one. It’s far easier than tightening types later.
Type the API at the boundary
Backends don’t always name things the way your app wants. I describe the API response as its own type and convert it once, where it enters the app. The rest of the code only ever sees clean, app-shaped types.
type ApiRide = { id: string; driver_name: string; seats_left: number };
function toRide(r: ApiRide): Ride {
return { id: r.id, driver: r.driver_name, seats: r.seats_left };
}
If the backend changes a field, there’s exactly one place to fix.
Type your navigation
Navigation is a common source of bugs: a screen expects a rideId and gets nothing. With React Navigation, a parameter list makes every route and its parameters checked:
import type { NativeStackScreenProps } from "@react-navigation/native-stack";
type RootStackParamList = {
Rides: undefined;
RideDetail: { rideId: string };
};
type Props = NativeStackScreenProps<RootStackParamList, "RideDetail">;
function RideDetail({ route }: Props) {
const { rideId } = route.params; // typed as string
// ...
}
Share types with the web
If you also have a React and TypeScript web app, the same types and business logic can live in a shared package. Your app, your web dashboard and your admin panel then agree on what a ride, an order or a user is.
When React Native is the right choice
- You need iOS and Android at launch, with one team.
- Your team already knows React and TypeScript.
- Most of the app is screens, lists, forms and API calls.
When I reach for Swift instead
- The app relies on heavy graphics, AR or advanced camera work.
- It depends on the newest Apple-only features.
- Smooth, platform-perfect animation is the product itself.
It doesn’t have to be all or nothing. Because iOS is my core, when a React Native app needs something the framework doesn’t cover, I write that part as a native module in Swift and keep the rest cross-platform.
Shipping to both stores
A cross-platform app still ships twice. I set up builds, signing and releases for both the App Store and Google Play early, ideally automated, so releasing is routine rather than a weekend project.
Nishanth Kumar