Get CroissantPay running in your React Native app in just 5 minutes.
Sign up for a free CroissantPay account to get your API keys.
Add the CroissantPay SDK to your React Native project.
# npm
npm install @croissantpay/react-native
# yarn
yarn add @croissantpay/react-native
# pnpm
pnpm add @croissantpay/react-nativeCreate an app in the CroissantPay dashboard and add your store credentials.
Wrap your app with the CroissantPay provider and start using purchases.
import { CroissantPayProvider } from '@croissantpay/react-native';
function App() {
return (
<CroissantPayProvider
apiKey="mx_public_your_key_here"
userId={currentUser.id} // Your app's user ID
apiUrl="https://api.croissantlabs.com" // Or your self-hosted URL
>
<YourApp />
</CroissantPayProvider>
);
}Use the usePurchases hook to display products and handle purchases.
import { usePurchases } from '@croissantpay/react-native';
function PaywallScreen() {
const {
offerings,
purchaseProduct,
hasEntitlement,
isLoading
} = usePurchases();
// Check if user already has access
if (hasEntitlement('premium')) {
return <Text>You're already a premium member!</Text>;
}
// Show loading state
if (isLoading || !offerings) {
return <ActivityIndicator />;
}
// Get current offering packages
const packages = offerings.current?.packages || [];
return (
<View>
<Text>Choose your plan</Text>
{packages.map(pkg => (
<TouchableOpacity
key={pkg.identifier}
onPress={() => purchaseProduct(pkg.product)}
>
<Text>{pkg.product.title}</Text>
<Text>{pkg.product.priceString}</Text>
<Text>{pkg.product.description}</Text>
</TouchableOpacity>
))}
</View>
);
}Gate features based on what the user has purchased.
import { usePurchases } from '@croissantpay/react-native';
function PremiumFeature() {
const { hasEntitlement, entitlements } = usePurchases();
// Simple check
if (!hasEntitlement('premium')) {
return <UpgradePrompt />;
}
// Or get full entitlement details
const premium = entitlements?.premium;
return (
<View>
<Text>Welcome, premium member!</Text>
{premium?.expiresAt && (
<Text>Renews: {new Date(premium.expiresAt).toLocaleDateString()}</Text>
)}
<PremiumContent />
</View>
);
}CroissantPay will automatically validate receipts, track subscriptions, and keep entitlements in sync across devices. Check the dashboard to monitor your subscribers and revenue.