๐ฐ Superwall
Dynamic paywall management for iOS and Android with remote configuration.
๐ก What is Superwall? Superwall is a paywall management platform that lets you design, test, and optimize subscription paywalls without releasing app updates. All paywall logic and UI are controlled remotely from the Superwall dashboard.
๐ฏ Architecture Overview
ExpoBase integrates Superwall using the official expo-superwall package with a declarative React Native approach. The integration separates business logic from paywall presentation - paywalls are managed dynamically from the Superwall dashboard, not coded in React Native.
Key Benefits
- No-code paywall updates - Change designs and copy without app releases
- A/B testing - Test different paywall variants to optimize conversions
- Remote triggers - Control when paywalls appear based on user events
- Native performance - Paywalls use native Apple Pay / Google Pay UI
๐๏ธ Technical Implementation
1. Provider Setup
The SuperwallProvider component wraps the entire application to make the SDK available everywhere. It initializes Superwall on app startup with API keys injected via environment variables.
File: context/SuperwallProvider.tsx
import React from 'react';
import { SuperwallProvider } from 'expo-superwall';
export default function Superwall({ children }: { children: React.ReactNode }) {
return (
<SuperwallProvider
apiKeys={{
ios: process.env.EXPO_PUBLIC_SUPERWALL_API_KEY_IOS ?? '',
android: process.env.EXPO_PUBLIC_SUPERWALL_API_KEY_ANDROID ?? '',
}}>
{children}
</SuperwallProvider>
);
}This provider wraps the app at the root level in app/_layout.tsx, right after the Authentication Context:
// Extract from app/_layout.tsx
<AuthProvider>
<SuperwallProvider>
<GestureHandlerRootView>
<Stack ... />
</GestureHandlerRootView>
</SuperwallProvider>
</AuthProvider>2. Native Configuration
For the native binaries (.ipa / .apk) to link the required native dependencies (C++/Swift SDK), the Expo plugin must be declared in app.json with expo-build-properties to ensure compatibility.
File: app.json
{
"expo": {
"plugins": [
"expo-superwall",
[
"expo-build-properties",
{
"ios": {
"deploymentTarget": "14.0",
"useFrameworks": "static"
},
"android": {
"minSdkVersion": 26
}
}
]
]
}
}โ ๏ธ Critical: The useFrameworks: "static" setting is essential for iOS compatibility with in-app purchase libraries.
3. Triggering Paywalls
Paywalls are triggered by events anywhere in the app using the useSuperwall hook. The app doesn't code the paywall design in React Native - it simply declares events, and Superwall's remote dashboard controls if/when a paywall appears.
Example: Triggering a paywall on a pricing screen
import { useSuperwall } from 'expo-superwall';
export default function PricingScreen() {
const { superwall } = useSuperwall();
const handleCheckout = () => {
// Register event with Superwall
// If the dashboard has a rule for 'campaign_trigger',
// the native paywall will animate onto screen and handle Apple Pay / Google Pay
superwall.registerEvent('campaign_trigger');
};
return (
<Button onPress={handleCheckout}>
Upgrade to Premium
</Button>
);
}- Developer calls
superwall.registerEvent('event_name') - Superwall SDK checks dashboard rules for this event
- If a paywall is configured for this event, it displays automatically
- Native payment UI (Apple Pay / Google Pay) handles the transaction
- Developer receives callback when purchase completes
๐ Setup Instructions
1. Create Superwall Account
- Go to superwall.com
- Create free account
- Create new project with your app name
2. Get API Keys
- In Superwall dashboard, go to Settings โ API Keys
- Copy your iOS API key
- Copy your Android API key
- Add both to your
.env.local:
# Superwall API Keys
EXPO_PUBLIC_SUPERWALL_API_KEY_IOS=pk_ios_xxxxxxxxxxxx
EXPO_PUBLIC_SUPERWALL_API_KEY_ANDROID=pk_android_xxxxxxxxxxxx
3. Configure Platforms
iOS Configuration
- In Superwall dashboard, go to Settings โ Platforms
- Select iOS
- Enter your Bundle ID (from
app.json) - Connect to App Store Connect (for product IDs)
- Save configuration
Android Configuration
- In Superwall dashboard, go to Settings โ Platforms
- Select Android
- Enter your Package Name (from
app.json) - Connect to Google Play Console (for product IDs)
- Save configuration
4. Create Your First Paywall
- Go to Paywalls in dashboard
- Click Create Paywall
- Choose a template or design from scratch
- Configure:
- Title and description
- Product offerings
- Call-to-action buttons
- Colors and branding
- Click Save
5. Create Event Triggers
- Go to Events in dashboard
- Click Create Event
- Enter event name (e.g.,
campaign_trigger,premium_feature_tap) - Choose which paywall to show
- Configure presentation rules:
- User segments
- Frequency caps
- A/B test variants
- Click Save
๐ป Usage Examples
Basic Paywall Trigger
import { useSuperwall } from 'expo-superwall';
function FeatureScreen() {
const { superwall } = useSuperwall();
const handlePremiumFeature = () => {
superwall.registerEvent('premium_feature_tap');
};
return (
<Button onPress={handlePremiumFeature}>
Unlock Premium Feature
</Button>
);
}Trigger with Custom Data
import { useSuperwall } from 'expo-superwall';
function ContentScreen({ contentId }: { contentId: string }) {
const { superwall } = useSuperwall();
const handleLockedContent = () => {
superwall.registerEvent('locked_content_tap', {
content_id: contentId,
content_type: 'article',
});
};
return (
<Button onPress={handleLockedContent}>
Read Full Article
</Button>
);
}Check Subscription Status
import { useSuperwall } from 'expo-superwall';
function ProfileScreen() {
const { superwall } = useSuperwall();
const [isPremium, setIsPremium] = React.useState(false);
React.useEffect(() => {
superwall.getSubscriptionStatus().then(status => {
setIsPremium(status === 'ACTIVE');
});
}, []);
return (
<View>
<Text>Status: {isPremium ? 'Premium' : 'Free'}</Text>
</View>
);
}๐จ Best Practices
Event Naming
Use descriptive, action-based event names:
โ Good:
onboarding_completedpremium_feature_tapsettings_upgrade_button
โ Bad:
event1clickbutton
Trigger Placement
Place events at natural conversion points:
- After onboarding - User understands app value
- Feature discovery - User tries to access premium feature
- Limit reached - User hits free tier limit
- Settings screen - User actively exploring premium
Testing
Always test paywalls in development:
# Build development version to test paywalls
npx expo run:ios
npx expo run:android๐ก Pro Tip: Use Superwall's test mode to preview paywalls without making real purchases during development.
๐ Troubleshooting
Paywall Not Showing
- Check event registration - Verify event name matches dashboard exactly
- Check targeting rules - Ensure you match the audience segment
- Check frequency caps - You may have already seen the paywall
- Check API keys - Verify keys are correct for the platform
API Key Issues
- Verify keys are set in
.env.local - Restart development server after changing keys
- Rebuild app if keys were added after initial build
- Check keys match your Superwall project
Products Not Loading
- Ensure products are configured in App Store Connect / Google Play
- Verify product IDs match in Superwall dashboard
- Check platform configuration in Superwall settings
- Wait for product sync (can take a few minutes)
Build Errors
If you get native build errors:
# Clean and rebuild
npx expo prebuild --cleanEnsure expo-build-properties is configured correctly in app.json (see Native Configuration section).
๐ Analytics & Optimization
Superwall automatically tracks:
- Impressions - How many times paywalls are shown
- Conversions - How many users subscribe
- Revenue - Total subscription revenue
- Variants - A/B test performance
Access analytics in the Superwall dashboard under Analytics.
A/B Testing
- Create multiple paywall variants
- Assign variants to the same event
- Set traffic split (e.g., 50/50)
- Monitor conversion rates
- Choose winning variant
๐ฏ Summary
In ExpoBase, Superwall integration follows these principles:
- API keys stored in
.env.local - SuperwallProvider boots SDK at launch
- expo-superwall linked via Expo plugin with static frameworks
- Developers trigger events like
registerEvent('premium_click') - Superwall dashboard controls when/how paywalls appear
This architecture separates presentation from logic - you control the triggers in code, Superwall controls the UI remotely.
๐ฏ Next Step
Continue to ๐ Revenue Cat to set up subscription management.
Step 5/12 Complete โ
Superwall paywalls configured for iOS & Android!
๐ Additional Resources
Official Documentation
- ๐ Superwall Documentation - Complete Superwall integration guide
- ๐ Expo Superwall Package - Official Expo package documentation
- ๐ฅ Superwall Video Tutorials - Video guides and best practices
