Handle Domains
Control which domains stay in the main webview, which open in the in-app browser, and which open in the device's browser
Handle Domains
Control how links behave in your app: keep them in the main webview, open them in an in-app browser, or send them to the device's browser.
How domain handling works
When a user taps a link, the app decides where to open it based on the domain:
- Internal domains load in the main webview — the user stays on your page.
- External domains — URLs matching a pattern you add with
addExternalDomains()— open in the device's browser (Safari, Chrome), outside the app. - Every other domain opens in an in-app browser — a browser view that appears on top of your app. The user can close it to return to your page.
By default, only the domain your app starts on is treated as internal, and there are no external patterns, so all other domains open in the in-app browser.
Add an internal domain
Internal domains load inside the app's webview:
await startiapp.App.addInternalDomain("partner-site.com");Add external domains
External domains are specified as RegExp patterns. A matching URL opens in the device's browser, even when it also matches an internal domain:
await startiapp.App.addExternalDomains(/maps\.google\.com/, /youtube\.com/);Remove domains
// Remove a specific internal domain
await startiapp.App.removeInternalDomain("partner-site.com");
// Remove external domain patterns
await startiapp.App.removeExternalDomains(/maps\.google\.com/);List configured domains
const internal = await startiapp.App.getInternalDomains();
const external = await startiapp.App.getExternalDomains();Handle all domains internally
This is especially useful for flows you don't fully control — for example, payment flows where the user is redirected through several third-party domains before returning to your site. Rather than adding each domain individually, you can treat everything as internal and only exclude specific domains that should open externally.
// Treat all domains as internal
await startiapp.App.handleAllDomainsInternally();
// But send specific ones to the device's browser
await startiapp.App.addExternalDomains(/maps\.google\.com/);When you no longer need all domains to be internal, call restoreDefaultDomainHandling() to go back to the default behavior:
await startiapp.App.restoreDefaultDomainHandling();handleAllDomainsInternally() is a session-only setting — it resets automatically when the app restarts. You only need to call restoreDefaultDomainHandling() if you want to revert during the same session.
Open a URL in the device's browser
To open one specific URL in the device's browser (Safari, Chrome) — completely outside the app — call openExternalBrowser(). External domains do the same for every link that matches a pattern.
await startiapp.App.openExternalBrowser("https://maps.google.com/?q=Copenhagen");