Skip to main content
Native iOS and Android billing fully bridged to your web layer. Trigger purchases, display native paywalls, and check entitlements from your web app using despia(), with no native code and no native billing SDK to configure.
RevenueCat must be enabled in Despia > App > Settings > Integrations > RevenueCat and your RevenueCat API key configured before any purchases will work.

Installation

npm install despia-native
import despia from 'despia-native';

How it works

Despia bridges your web layer to the native RevenueCat SDK. Purchases go through the App Store or Google Play billing system. When a transaction completes, the runtime fires window.onRevenueCatPurchase() in your web layer. You can then check entitlements instantly using getpurchasehistory://, which queries the native store directly with no backend needed.
// Check entitlements on load and after every purchase
const data   = await despia('getpurchasehistory://', ['restoredData'])
const active = (data.restoredData ?? []).filter(p => p.isActive)

if (active.some(p => p.entitlementId === 'premium')) unlockPremium()
For users on the web app who are not in the Despia WebView, fall back to a RevenueCat Web Purchase Link with the user’s ID appended.
const isDespia = navigator.userAgent.toLowerCase().includes('despia')

if (isDespia) {
    despia(`revenuecat://launchPaywall?external_id=${userId}&offering=default`)
} else {
    window.location.href = `https://pay.rev.cat/<your_token>/${encodeURIComponent(userId)}`
}

Reference

All schemes, parameters, response fields, callback behaviour, and webhook setup.

Webhooks

Full backend webhook handler covering all RevenueCat event types.

Entitlement check

Set up entitlements in your RevenueCat dashboard first. Create an entitlement (e.g. premium), then attach both your iOS and Android products to it. Both platforms will return the same entitlementId in the response.
// Reuse this function on app load, page navigation, and in onRevenueCatPurchase
async function checkEntitlements() {
    const data   = await despia('getpurchasehistory://', ['restoredData'])
    const active = (data.restoredData ?? []).filter(p => p.isActive)

    if (active.some(p => p.entitlementId === 'premium')) unlockPremium()
    if (active.some(p => p.entitlementId === 'no_ads'))  removeAds()
}

checkEntitlements()
window.onRevenueCatPurchase = checkEntitlements

Resources

NPM Package

despia-native

RevenueCat Dashboard

Configure entitlements, offerings, and paywalls

RevenueCat Webhooks

Event types, fields, and sample payloads