croissantlabs-react-native
v0.1.0
Published
CroissantLabs SDK for React Native — in-app subscriptions, offerings, entitlements
Downloads
91
Maintainers
Readme
CroissantLabs SDK (React Native)
React Native SDK for CroissantLabs: in-app subscriptions, offerings, entitlements, and restore.
Full native IAP: opens App Store / Play Store, syncs receipts with CroissantLabs, and restores purchases.
V1 targets React Native and is Expo-compatible.
Installation
Install the SDK and the native IAP peer dependency:
npm
npm install croissantlabs-react-native react-native-iapYarn / pnpm
yarn add croissantlabs-react-native react-native-iap
pnpm add croissantlabs-react-native react-native-iapExpo
If you use Expo, prefer the Expo-compatible install so peer dependencies match your Expo SDK:
npx expo install croissantlabs-react-native react-native-iapPrerequisites
- React Native 0.64+ (or Expo SDK 48+)
- react-native-iap ^12.x or ^13.x (peer dependency; required for purchases)
- A CroissantLabs project and API key from the CroissantLabs dashboard (or self-hosted platform)
- iOS: deployment target 13.4+
- Android: minSdkVersion 23+
Quick start
import CroissantLabs from 'croissantlabs-react-native';
// 1. Configure (e.g. in App.tsx or root component)
useEffect(() => {
CroissantLabs.configure({ apiKey: 'YOUR_PUBLIC_API_KEY' });
}, []);
// 2. Optional: identify your user
CroissantLabs.identify('user_123');
// 3. Get offerings and show paywall
const offerings = await CroissantLabs.getOfferings();
const package = offerings.current?.availablePackages[0];
if (package) {
const { customerInfo } = await CroissantLabs.purchasePackage(package);
// Check customerInfo.entitlements.active['premium']
}
// 4. Check entitlements
const customerInfo = await CroissantLabs.getCustomerInfo();
const hasPremium = customerInfo.entitlements.active['premium'] != null;
// 5. Restore purchases
const restored = await CroissantLabs.restorePurchases();API overview
| Method | Description |
|--------|-------------|
| configure(options) | Initialize with API key and optional base URL. |
| identify(userId) | Set app user id for this device/session. |
| getOfferings() | Fetch current offerings and packages. |
| purchasePackage(package) | Open native store, purchase, sync receipt with CroissantLabs. |
| getCustomerInfo() | Get current entitlements and subscription status. |
| restorePurchases() | Restore from store and sync with CroissantLabs. |
Documentation
License
See repository license. CroissantLabs SDK is open source.
