React Native SDK Guide
⚛️ React Native — native paywalls with a thin JS bridge
The React Native SDK is a thin bridge: the JS layer delegates to the native BillDog iOS and Android SDKs rather than reimplementing billing logic, so paywalls and purchases behave identically to the native guides.
1. Install
npm install @billdog.io/react-native@^1.2.0-beta.1 \
@react-native-async-storage/async-storage@^1.19.0 \
react-native-fs@^2.20.0 \
react-native-svg@^13.0.0 \
react-native-webview@^13.0.0The four packages after the SDK are its peer dependencies. They contain native code, and React Native autolinks only the packages listed in your app’s own package.json — not the dependencies of the packages you install — so they are installed by name, within the ranges the SDK declares. With them in place, no manual native registration is needed. On iOS, install the pods:
cd ios && pod installThe local-notification helpers (NotificationScheduler, useDeviceToken, the notification-permission functions) use react-native-push-notification and, on iOS, @react-native-community/push-notification-ios. They are optional peers: install them only if you call those helpers. Without them the app still builds and runs; the helpers fail with a BillDogApiError whose code is NATIVE_MODULE_UNAVAILABLE (their promises reject, and useDeviceToken passes it to onError), and isNotificationSupported() returns false.
iOS requires a 15.0 deployment target
BillDogFull) requires iOS 15.0. React Native’s template sets platform :ios, min_ios_version_supported, which is 15.1 from React Native 0.76 and satisfies this. On React Native 0.75 and earlier it is 13.4 or lower, so set platform :ios, '15.0' in your Podfile (and the iOS Deployment Target of your app target in Xcode), or pod install will fail.2. Configure
Configure once, before you render. Note the named import — the package has no default export — and that configure is on BillDogConfiguration, not on BillDog.
import { BillDogConfiguration } from '@billdog.io/react-native';
BillDogConfiguration.configure({
apiKey: 'YOUR_API_KEY_HERE', // starts with bd_public_test_ or bd_public_live_
});That also starts analytics: the native SDK registers its analytics module when it is configured, so there is no separate initialize step.
import { BillDog } from '@billdog.io/react-native';
BillDog.isConfigured(); // -> boolean: did the SDK pick up your key?3. Manage customer identity
Link anonymous sessions to your accounts so entitlements follow the user across devices.
This links a user you have already authenticated elsewhere
import { BillDog } from '@billdog.io/react-native';
// Link this device to your account id
await BillDog.logIn('user_uuid_123');
// Or identify with attributes for segmentation
await BillDog.identify('user_uuid_123', { plan: 'trial' });
BillDog.isAnonymous(); // -> boolean
BillDog.getAppUserId(); // -> string | null
// On logout: continue as a NEW anonymous user (a fresh anonymous id)
await BillDog.logOut();4. Present a paywall
The recommended entry point is a placement: BillDog decides which paywall (if any) to show, applying your targeting and holdout rules.
import { BillDog } from '@billdog.io/react-native';
const result = await BillDog.register('onboarding');
// result.type: 'entitled' | 'purchased' | 'dismissed' | 'restored'
// | 'holdout' | 'withheld' | 'error'To render a specific paywall inline instead, use the PaywallView component:
import { PaywallView } from '@billdog.io/react-native';
export function PremiumScreen() {
return <PaywallView paywallIdentifier="premium_offer" />;
}There is also a usePaywall hook for fetching configuration without rendering, plus useOfferings and usePlacement.
5. Check entitlements
Gate features on entitlements rather than on product ids.
import { BillDog } from '@billdog.io/react-native';
// Asks the server; false on any error (fails closed)
if (await BillDog.hasAccessForPlacement('premium_features')) {
// unlock
}
// Or read the full customer record
const info = await BillDog.getCustomerInfo();
const hasPro = info?.entitlements.some(
(e) => e.identifier === 'pro' && e.isActive
);
// Restore purchases (e.g. from a "Restore" button)
await BillDog.restore();Entitlements are a list, not a map
CustomerInfo.entitlements is an array of EntitlementInfo (identifier, isActive, expiresAt, willRenew, isLifetime…), so check it with .some(...) rather than indexing by key.6. Track events
Analytics lives on the AnalyticsManager singleton — BillDog itself has no track method. It is ready once configure() (section 2) has run.
import { AnalyticsManager } from '@billdog.io/react-native';
const analytics = AnalyticsManager.getInstance();
await analytics.track('app_opened', { source: 'cold_start' });
await analytics.trackRevenue({ amount: 9.99, currency: 'USD' });7. Sign users in (BillDog Auth)
Requires native binaries 1.0.2-beta.3 or later (use 1.2.0-beta.1)
BillDogFull built before that module was written (the 2026-08-08 build) contains no BillDogAuth, and Maven Central carries no io.billdog:billdog-auth before 1.0.2-beta.3. A build that resolves an older binary fails to compile — this is not a missing method or two, it is the whole module.Like the rest of the package, auth is a thin bridge. It could have been written in TypeScript — it is plain HTTPS — but then the refresh token would live in AsyncStorage, which is neither encrypted nor excluded from cloud backup. Delegating keeps it in the iOS Keychain and Android EncryptedSharedPreferences. The session token is never handed to JS at all: it lives ninety seconds and the native API clients already attach it.
import { BillDogAuth } from '@billdog.io/react-native';
// False when the native module is not linked into the host app.
if (!BillDogAuth.isAvailable) return;
const restored = await BillDogAuth.restore(); // { signedIn: false } on first launch
// signedIn: false + hasStoredSession: true → offline or a server error, still signed in
const r = await BillDogAuth.attempt({
identifier: 'ada@example.com',
strategy: 'password',
password,
});
// Check this BEFORE treating it as a sign-in: against an enrolled account a
// correct password issues no session.
if (r.mfaRequired) {
await BillDogAuth.attempt({
identifier: 'ada@example.com',
strategy: 'totp',
code,
mfaToken: r.mfaToken, // proves the first factor was accepted
});
}A wrong second factor is a restart, not a retry
mfaToken. Send the user back to the first factor for a new one; re-calling attempt with the same token cannot succeed. See Multi-factor.Passwordless, and phone numbers
// A RETURNING user gets a fresh code from requestCode. Without it a code could
// only be obtained as a side effect of signing up.
await BillDogAuth.requestCode({ identifier: '+15551234567', kind: 'phone' });
await BillDogAuth.attempt({
identifier: '+15551234567',
kind: 'phone', // REQUIRED — selects the identity row
strategy: 'sms_code',
code,
});kind defaults to 'email' and selects the identity row
The rest of the surface
isSignedIn(), signUp(...) (below), signOut('this' | 'others' | 'all'), passkeysAvailable(), registerPasskey(label?), signInWithPasskey(), and BillDogAuth.organizations — create, list, members, roles, invitations, domains.
The token carries the user’s entitlements in the ent claim, capped at 64 with ent_truncated set past that — read Sessions & tokens before you treat ent as a complete list.
Sign-up requirements, password reset and account deletion
// What the project requires before it accepts a sign-up
const cfg = await BillDogAuth.config(); // { accessMode, botProtection, turnstileSiteKey, ... }
await BillDogAuth.signUp({
identifier: 'ada@example.com',
password,
invitationToken, // required when cfg.accessMode is 'invite_only'
captchaToken, // required when cfg.botProtection is true (a Turnstile token)
});
// Password reset: send a code, then set the new password with it.
// Pass the same kind to both calls for a phone number.
await BillDogAuth.requestPasswordReset({ identifier: 'ada@example.com' });
await BillDogAuth.resetPassword({ identifier: 'ada@example.com', code, newPassword });
// Delete the signed-in user's own account. Rejects with code REAUTH_REQUIRED
// when the sign-in is too old: sign the user in again, then retry.
await BillDogAuth.deleteAccount();Next steps
- Using Expo? See the Expo SDK guide — the config plugin wires the native project for you.
- The bridge delegates to the native SDKs; for platform behaviour see the iOS and Android guides.
- BillDog Auth — sign users in, and gate features on the token. Start at the quickstart.
- SDK glossary — placements, offerings and entitlements explained.
Was this page helpful?
Or rate this page: