navigator.userAgent to detect this and conditionally render platform-specific features, such as showing RevenueCat in-app purchase buttons when running natively in Despia, or Stripe checkout buttons when running in a standard web browser.
Installation
No installation required! The user agent string is automatically set by the browser/runtime environment.Usage
1. Basic Platform Detection
2. Conditional Feature Rendering
3. Platform-Specific UI
Resources
- User Agent Check:
navigator.userAgent.toLowerCase().includes('despia') - iOS Detection: Check for “iphone” or “ipad” in user agent
- Android Detection: Check for “android” in user agent
- Automatically available in all JavaScript environments
- No external packages or configuration needed