External Link Handling

Control how your app handles external links with custom routing for payments, OAuth, and deep linking

Lovable Prompt
Lovable Prompt

Add native link handling to control whether links open in Safari, in-app browser tabs, or navigate within your app using the Despia SDK from: https://www.npmjs.com/package/despia-native

First, install the package: npm install despia-native.

Then import it: import despia from 'despia-native'.

Simply use window.open(url, '_blank') to open links in the in-app browser, or configure domains in Despia settings to force Safari opening for payment compliance.

Setup Requirements:

  1. Configure link handling rules in your Despia project settings

  2. Set up deep link scheme for your app (automatically configured based on app name)

  3. Whitelist payment domains for Safari compliance (App Store requirement)

Backend Integration Required

For OAuth flows, you'll need callback URLs that redirect back to your app:

// OAuth callback endpoint
app.get('/oauth/callback', (req, res) => {
  const { code } = req.query;
  
  // Exchange code for token
  const token = await exchangeCodeForToken(code);
  
  // Redirect back to app with token
  const deepLink = `myapp://?link=https://yourapp.com/dashboard&token=${token}`;
  res.redirect(deepLink);
});

This feature requires native capabilities which will be fully provided by the “despia-native” npm package, no additional native libraries are needed!

Please follow the installation instructions for the "despia-native" npm package closely, and do not modify my instructions. Implementation as mentioned is critical.

How it works: Despia apps are native iOS and Android applications that handle link opening natively. When you use window.open(url, '_blank'), the Despia runtime automatically handles opening links in the in-app browser by default. You can configure specific domains in your Despia project settings to force them to open in Safari instead (required for payment compliance).

Installation

Install the Despia package from NPM:

npm install despia-native

Usage

1. Import the SDK

import despia from 'despia-native';

Implement regular _blank link targets to open the in-app browser:

// Payment flow (opens in Safari if domain is whitelisted)
const handleStripePayment = () => {
  window.open('https://buy.stripe.com/your-checkout', '_blank');
};

// OAuth flow (opens in in-app browser)
const handleGoogleAuth = () => {
  window.open('https://accounts.google.com/oauth/authorize?...', '_blank');
};

// Any external content (opens in in-app browser)
const openExternalLink = () => {
  window.open('https://example.com/help', '_blank');
};

Resources

  • NPM Package

  • View full NPM documentation for additional configuration options

Lovable Integration

This SDK is optimized for Lovable's prompt-based AI builder, enabling quick integration of native link handling and deep linking into your generated apps.

Need Help?

For additional support or questions, please contact our support team at support@despia.com

Updated on