
Learn how to build high-converting mobile app paywalls in React Native using RevenueCat for seamless in-app purchases.
When I built Nept Track, my offline habit tracker and budget app in React Native, one of the biggest challenges was not just writing the app logic, but figuring out how to charge for it sustainably. Mobile app monetization can quickly turn into a headache when you have to manage Apple App Store Connect, Google Play Console, receipt validation, and subscription statuses all at once.
Over time, I learned that handling payments natively without a solid abstraction layer is a recipe for endless debugging sessions. That is why I started using RevenueCat for my mobile projects. In this guide, I want to share a practical, developer-centric walkthrough of how to set up RevenueCat paywalls in a React Native application to handle subscriptions and in-app purchases cleanly.
Building an in-app purchase system from scratch means dealing with store-specific APIs, backend receipt validation servers, and edge cases like subscription renewals, refunds, and grace periods.
RevenueCat acts as a unified layer over StoreKit (iOS) and Google Play Billing (Android). Instead of writing platform-specific purchase code, you call a single SDK method. It also gives you a dashboard to analyze churn, trial conversions, and active subscriptions without writing custom analytics code.
First, install the RevenueCat SDK in your React Native or Expo project. If you are using standard React Native CLI, run:
npm install react-native-purchases
If you are using Expo, make sure you configure your development builds properly, as native modules require a custom development client rather than the standard Expo Go app.
Next, initialize the SDK inside your root component or entry point, usually App.tsx or _layouttsx in Expo Router:
import Purchases from 'react-native-purchases';
import { useEffect } from 'react';
export default function App() {
useEffect(() => {
if (Platform.OS === 'ios') {
Purchases.configure({ apiKey: 'appl_your_ios_api_key' });
} else if (Platform.OS === 'android') {
Purchases.configure({ apiKey: 'goog_your_android_api_key' });
}
}, []);
return (
// Your app navigation or root layout
);
}
Tagged with
Leave a comment
RevenueCat uses the concept of "Offerings." An offering is a group of products you want to display on a paywall. You configure your products in App Store Connect and Google Play Console, group them in the RevenueCat dashboard, and fetch them dynamically in your app code.
Here is how you fetch the current offering to display pricing:
import { useState, useEffect } from 'react';
import Purchases, { PACKAGE_TYPE, PurchasesPackage } from 'react-native-purchases';
import { View, Text, TouchableOpacity, StyleSheet } from 'react-native';
export function PaywallScreen() {
const [monthlyPackage, setMonthlyPackage] = useState<PurchasesPackage | null>(null);
const [loading, setLoading] = useState(true);
useEffect(() => {
async function loadOfferings() {
try {
const offerings = await Purchases.getOfferings();
if (offerings.current && offerings.current.monthly) {
setMonthlyPackage(offerings.current.monthly);
}
} catch (error) {
console.error('Error fetching offerings:', error);
} finally {
setLoading(false);
}
}
loadOfferings();
}, []);
const handlePurchase = async (pkg: PurchasesPackage) => {
try {
const { customerInfo } = await Purchases.purchasePackage(pkg);
if (customerInfo.entitlements.active['pro_access']) {
// Unlock premium features
console.log('Purchase successful!');
}
} catch (error: any) {
if (!error.userCancelled) {
console.error('Purchase failed:', error);
}
}
};
if (loading) {
return <View><Text>Loading paywall...</Text></View>;
}
return (
<View style={styles.container}>
<Text style={styles.title}>Unlock Pro Features</Text>
{monthlyPackage && (
<TouchableOpacity
style={styles.button}
onPress={() => handlePurchase(monthlyPackage)}
>
<Text style={styles.buttonText}>
Subscribe for {monthlyPackage.product.priceString} / month
</Text>
</TouchableOpacity>
)}
</View>
);
}
const styles = StyleSheet.create({
container: { flex: 1, justifyContent: 'center', alignItems: 'center', padding: 20 },
title: { fontSize: 24, fontWeight: 'bold', marginBottom: 20 },
button: { backgroundColor: '#007AFF', padding: 16, borderRadius: 8, width: '100%', alignItems: 'center' },
buttonText: { color: '#fff', fontSize: 16, fontWeight: '600' }
});
Once a user purchases a subscription, you need to check if they have active access whenever they open restricted parts of your app. RevenueCat handles entitlement checking through customer info objects.
import Purchases from 'react-native-purchases';
export async function checkProStatus(): Promise<boolean> {
try {
const customerInfo = await Purchases.getCustomerInfo();
return typeof customerInfo.entitlements.active['pro_access'] !== 'undefined';
} catch (error) {
console.error('Failed to get customer info', error);
return false;
}
}
Apple and Google guidelines strictly require every app with in-app purchases to provide a "Restore Purchases" button. If a user reinstalls your app or switches devices, they should be able to recover their active subscription without paying again.
Implementation is straightforward with RevenueCat:
const handleRestore = async () => {
try {
const customerInfo = await Purchases.restorePurchases();
if (customerInfo.entitlements.active['pro_access']) {
console.log('Purchases successfully restored');
// Navigate user to the main app screen
} else {
console.log('No active subscriptions found to restore');
}
} catch (error) {
console.error('Restore failed:', error);
};
};
Need help setting up robust in-app purchases, custom paywalls, or scaling a full-stack mobile application? Get in touch and let's talk about your project.