Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.pnlight.app/llms.txt

Use this file to discover all available pages before exploring further.

Use @pnlight/sdk-react-native for React Native apps that need PNLight on iOS.

Install

npm install @pnlight/sdk-react-native
The current npm package version is 0.5.2.
The package includes optional Expo support. If you use Expo, rebuild the native app after adding the package.

Initialize the SDK

Call initialize once during app startup.
import { initialize } from "@pnlight/sdk-react-native";

await initialize("pnlight_sdk_token");

Common calls

import {
  addAttribution,
  getUserId,
  logEvent,
  validatePurchase,
} from "@pnlight/sdk-react-native";

const userId = await getUserId();
const isAllowed = await validatePurchase();

await logEvent("purchase_completed", {
  product_id: "premium_subscription",
  amount: 9.99,
});

await addAttribution(
  "appsFlyer",
  { af_status: "Non-organic" },
  "appsFlyerCustomerId"
);

Server-driven UI component

Use RemoteUiView to fetch and render a placement.
import { RemoteUiView } from "@pnlight/sdk-react-native";

export function PaywallScreen() {
  return (
    <RemoteUiView
      placement="paywall"
      cardId="paywall_card"
      style={{ flex: 1 }}
      onAction={(event) => {
        if (event.logId === "purchase_button") {
          startPurchase(event.params.id);
        }
      }}
    />
  );
}

Server-driven UI props

PropTypeDescription
placementstringPlacement ID configured in PNLight.
cardIdstringOptional card ID. Defaults to a placement-based value.
securebooleanPrevents screenshots and recordings when enabled. Defaults to true.
preventRecordingbooleanBlocks the rendered UI after a capture attempt when enabled. Defaults to true.
attributionRequiredbooleanWaits for attribution before returning a config when enabled. Defaults to true.
onActionfunctionHandles custom actions from the rendered UI.
Use server-driven UI to learn how placements and actions work.