Skip to main content
Web entitlements enable apps that sell subscriptions via web checkout (e.g., Stripe) to unlock premium features in the native app in real-time. After calling identify(), the SDK listens for entitlement changes automatically.

How It Works

  1. User purchases a subscription on your website.
  2. Your backend writes the entitlement to AppDNA.
  3. The SDK detects the change in real-time.
  4. Your app reacts via the callback and unlocks premium features.
Web entitlements are separate from in-app purchase entitlements. They are designed for apps that also sell subscriptions through a web checkout flow.

Check Current Entitlement

After identify(), the current web entitlement is available synchronously:
const entitlement = AppDNA.billing.webEntitlement;

if (entitlement && entitlement.is_active) {
  unlockPremium();
  console.log(`Plan: ${entitlement.plan_name}, Status: ${entitlement.status}`);
}

Listen for Changes

const unsubscribe = AppDNA.billing.onWebEntitlementChanged(
  (entitlement: WebEntitlement | null) => {
    if (entitlement?.is_active) {
      unlockPremium();
    } else {
      lockPremium();
    }
  }
);

// Clean up
unsubscribe();

WebEntitlement

PropertyTypeDescription
is_activebooleanWhether the subscription is currently active
plan_namestringName of the subscription plan
product_idstringProduct identifier
statusstringCurrent status
expires_atstring | nullExpiration date (ISO 8601)

Entitlement Statuses

StatusDescription
activeSubscription is active and paid
trialingUser is in a free trial period
past_duePayment failed, in grace period
canceledSubscription is canceled

Auto-Tracked Events

EventTrigger
web_entitlement_activatedWeb subscription becomes active
web_entitlement_expiredWeb subscription expires or is canceled

Full Example

import { AppDNA, WebEntitlement } from "@appdna/react-native-sdk";
import React, { useEffect, useState } from "react";

function usePremiumAccess() {
  const [hasAccess, setHasAccess] = useState(false);

  useEffect(() => {
    // Check on mount
    checkAccess();

    // Listen for web entitlement changes
    const unsubscribe = AppDNA.billing.onWebEntitlementChanged(
      (entitlement) => {
        if (entitlement?.is_active) {
          setHasAccess(true);
        } else {
          checkAccess();
        }
      }
    );

    return () => unsubscribe();
  }, []);

  async function checkAccess() {
    // Check in-app purchase entitlements
    const hasIAP = await AppDNA.billing.hasActiveSubscription();
    if (hasIAP) {
      setHasAccess(true);
      return;
    }

    // Check web entitlement
    const web = AppDNA.billing.webEntitlement;
    setHasAccess(web?.is_active ?? false);
  }

  return hasAccess;
}

// Usage
function PremiumContent() {
  const hasAccess = usePremiumAccess();

  if (!hasAccess) {
    return <UpgradePrompt />;
  }

  return <>{/* Premium content */}</>;
}
Web entitlements require Stripe integration configured in the Console under Settings > Billing > Web Payments. The real-time listener activates after identify() is called.