npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-native-crp

v0.1.0

Published

React Native SDK for CroissantPay - In-app purchase and subscription management

Readme

react-native-crp

React Native SDK for CroissantPay - Self-hosted in-app purchase and subscription management.

Note: CRP stands for CRoissantPay.

Installation

npm install react-native-crp
# or
yarn add react-native-crp

For local development (linking from example-crp):

# In example-crp/package.json, add:
"react-native-crp": "file:../react-native-crp"

iOS

cd ios && pod install

Android

No additional steps required.

Quick Start

1. Initialize the SDK

import { CroissantPay } from 'react-native-crp';

// In your app initialization
await CroissantPay.configure({
  apiKey: 'mx_public_your_api_key',
  apiUrl: 'https://your-croissantpay-instance.com', // Your CroissantPay server URL
  appUserId: 'user_123', // Optional: identify user immediately
  debugLogs: __DEV__,
});

2. Using the Provider (Recommended)

import { CroissantPayProvider, usePurchases } from 'react-native-crp';

function App() {
  return (
    <CroissantPayProvider
      config={{
        apiKey: 'mx_public_your_api_key',
        apiUrl: 'https://your-croissantpay-instance.com',
        appUserId: 'user_123',
      }}
    >
      <YourApp />
    </CroissantPayProvider>
  );
}

function PaywallScreen() {
  const { offerings, purchase, isLoading, hasEntitlement } = usePurchases();

  if (hasEntitlement('premium')) {
    return <PremiumContent />;
  }

  const currentOffering = offerings?.offerings[offerings.currentOfferingId!];

  return (
    <View>
      {currentOffering?.products.map((product) => (
        <TouchableOpacity
          key={product.identifier}
          onPress={() => purchase(product.identifier)}
          disabled={isLoading}
        >
          <Text>{product.displayName}</Text>
          <Text>{product.priceString}</Text>
        </TouchableOpacity>
      ))}
    </View>
  );
}

3. Direct SDK Usage

import { CroissantPay } from 'react-native-crp';

// Get subscriber info
const subscriberInfo = await CroissantPay.getSubscriberInfo();

// Check entitlements
if (subscriberInfo.entitlements.premium?.isActive) {
  // User has premium access
}

// Get offerings
const offerings = await CroissantPay.getOfferings();

// Make a purchase
const result = await CroissantPay.purchase('monthly_premium');
if (result.success) {
  console.log('Purchase successful!');
}

// Restore purchases
const restoreResult = await CroissantPay.restorePurchases();

API Reference

CroissantPay

configure(config: CroissantPayConfig): Promise<void>

Initialize the SDK with your configuration.

interface CroissantPayConfig {
  apiKey: string;        // Your CroissantPay public API key
  apiUrl?: string;       // Your CroissantPay server URL
  appUserId?: string;    // User ID to identify immediately
  debugLogs?: boolean;   // Enable debug logging
}

identify(appUserId: string): Promise<SubscriberInfo>

Identify the current user. Call this when a user logs in.

getSubscriberInfo(): Promise<SubscriberInfo>

Get the current subscriber's info and entitlements.

getOfferings(): Promise<Offerings>

Get available product offerings.

purchase(productIdentifier: string): Promise<PurchaseResult>

Initiate a purchase for the given product.

restorePurchases(): Promise<RestoreResult>

Restore previous purchases. Call this to restore purchases for returning users.

setAttributes(attributes: Record<string, unknown>): Promise<void>

Set custom attributes for the subscriber.

Hooks

usePurchases()

Main hook for accessing purchase functionality.

const {
  isConfigured,    // boolean
  isLoading,       // boolean
  subscriberInfo,  // SubscriberInfo | null
  offerings,       // Offerings | null
  error,           // Error | null
  identify,        // (appUserId: string) => Promise<SubscriberInfo | null>
  purchase,        // (productId: string) => Promise<PurchaseResult | null>
  restore,         // () => Promise<RestoreResult | null>
  refresh,         // () => Promise<void>
  hasEntitlement,  // (entitlementId: string) => boolean
} = usePurchases();

useEntitlement(entitlementId: string)

Check a specific entitlement.

const { entitlement, isActive, isLoading } = useEntitlement('premium');

useCurrentOffering()

Get the current default offering.

const { offering, isLoading } = useCurrentOffering();

Types

SubscriberInfo

interface SubscriberInfo {
  appUserId: string;
  entitlements: Record<string, Entitlement>;
  activeSubscriptions: string[];
  nonSubscriptionPurchases: Array<{
    productIdentifier: string;
    purchaseDate: Date;
    transactionId: string;
  }>;
}

Entitlement

interface Entitlement {
  identifier: string;
  isActive: boolean;
  expiresDate: Date | null;
  productIdentifier: string | null;
  willRenew: boolean;
  periodType: 'normal' | 'trial' | 'intro';
  isSandbox: boolean;
}

Product

interface Product {
  identifier: string;
  storeProductId: string;
  displayName: string;
  description: string | null;
  price?: string;
  priceString?: string;
  currencyCode?: string;
  subscriptionPeriod: string | null;
  trialDuration: string | null;
}

License

MIT