Configuration Errors
Configuration errors occur when the SDK fails to initialize, typically due to network issues, invalid API keys, or offline scenarios.Using the SuperwallError Component
TheSuperwallError component displays UI when SDK initialization fails:
The
SuperwallError component accepts either static React nodes or a render function that receives the error message string.Using the onConfigurationError Callback
Handle configuration errors programmatically for logging or analytics:Accessing Error State Directly
Access configuration errors programmatically usinguseSuperwall:
Paywall Errors
Handle errors that occur during paywall presentation or interaction.Using onError Callback
TheusePlacement hook provides an onError callback:
Checking Paywall State
Thestate object from usePlacement includes error information:
Paywall Skip Reasons
Handle cases where paywalls are intentionally not shown:Transaction Errors
Handle purchase and restore transaction failures:Restore Failed Errors
Customize the restore failure alert in provider options:Logging for Debugging
Enable detailed logging during development:Log Levels
"debug"- Verbose logging for development"info"- General information messages"warn"- Warning messages"error"- Error messages only"none"- Disable all logging
Capturing Logs
Subscribe to SDK logs for custom logging:Complete Error Handling Example
Here’s a comprehensive error handling setup:Best Practices
Always handle configuration errors
Always handle configuration errors
Never assume SDK initialization will succeed. Always handle configuration errors with the
SuperwallError component or onConfigurationError callback.Provide user-friendly messages
Provide user-friendly messages
Don’t show raw error messages to users. Provide clear, actionable messages:
- ✅ “Unable to load subscription page. Please try again.”
- ❌ “Error: Network request failed: timeout of 30000ms exceeded”
Log errors for debugging
Log errors for debugging
Always log errors to your analytics and error tracking service:
Handle offline gracefully
Handle offline gracefully
The SDK handles offline scenarios automatically, but you should still provide feedback:
Use debug logging in development
Use debug logging in development
Enable verbose logging during development:
Next Steps
Provider Setup
Learn about all provider configuration options
Displaying Paywalls
Handle paywall presentation and callbacks