RevenueCat Documentation
Overview
RevenueCat is integrated into this React Native app for subscription management, in-app purchases, and revenue analytics. It handles subscriptions across iOS App Store and Google Play Store, providing a unified API for managing purchases, entitlements, and customer data.
Configuration
RevenueCat is configured in app/_layout.tsx:
- API Key: Set via
EXPO_PUBLIC_REVENUE_CAT_PUBLIC_API_KEYenvironment variable - Log Level: Set to
DEBUGfor development - Platform Support: iOS and Android
- Packages: Uses
react-native-purchasesandreact-native-purchases-ui
Integration Details
Custom Hook: useSubscription
The app uses a custom hook hooks/useSubscription.ts that provides:
const {
// State
customerInfo, // Current customer information
subscriptionInfo, // Active subscription details
error, // Error messages
isSubscribed, // Boolean: is user subscribed?
packages, // Available purchase packages
// Actions
restorePurchases, // Restore previous purchases
purchaseSubscription, // Purchase a subscription package
manageSubscriptions, // Open subscription management (iOS only)
refreshCustomerInfo, // Refresh customer data
} = useSubscription();RevenueCat UI Component
The app also includes a pre-built paywall using RevenueCatUI.Paywall (see app/offering.tsx):
<RevenueCatUI.Paywall
onPurchaseStarted={handlePurchaseStarted}
onPurchaseCompleted={handlePurchaseCompleted}
onPurchaseError={handlePurchaseError}
onRestoreStarted={handleRestoreStarted}
onRestoreCompleted={handleRestoreCompleted}
onRestoreError={handleRestoreError}
/>Environment Setup
Add your RevenueCat API key to your environment variables:
- Log in to RevenueCat Dashboard
- Select your project
- Navigate to the dashboard
- Go to Settings → API Keys
- Copy the SDK API Key for your platform and add it to your
.envfile:
EXPO_PUBLIC_REVENUE_CAT_PUBLIC_API_KEY=your_public_api_key_here