All articles

Guide

Managing Multi-Origin and Subdomain PWAs in a TWA

August 25, 2026 · 7 min read

A common architectural requirement for modern Software-as-a-Service platforms, ecommerce networks, and enterprise web applications is the division of services across multiple domains or subdomains. A company might host its marketing landing pages on one domain, its core application logic on a dedicated subdomain, and its identity verification or payment gateway on external origins.

When launching this structure inside an Android Trusted Web Activity, this multi-origin architecture presents a technical challenge. If a user navigates to an origin that has not been explicitly validated, the TWA wrapper reverts to showing the standard browser URL address bar, destroying the native application illusion. To prevent this, developers must properly configure multi-origin Digital Asset Links and update their Android build settings.

The Core TWA Navigation Security Model

Trusted Web Activities rely on a strict security protocol to verify ownership of the web domains being rendered. This is achieved via Digital Asset Links, a declaration file hosted at the path of your domain. Before Chrome hides the browser interface elements inside your app container, it verifies that the signature of the Android APK or AAB matches the signature declared in the assetlinks.json file on the server.

If your application navigates from your primary domain to an unverified subdomain, Chrome assumes the user is leaving the verified application scope. To protect user privacy and prevent spoofing attacks, it instantly displays the browser address bar. Consequently, if your application spans multiple origins, every single one of those origins must be declared in both the Android app build configuration and on the respective web servers.

Configuring the Android Wrapper for Multiple Origins

To enable multi-origin support, the Android build configuration must know which additional domains are considered part of the application. This is typically configured in the build variables or the resource manifest of your TWA project.

In standard TWA projects, the primary origin is defined under a single resource string, while additional origins are passed as an array. The system processes these additional domains and registers them as valid intents for the application activity.

Configuration PropertySingle-Origin ScopeMulti-Origin Scope
launchUrlThe startup URL of the application.The primary landing URL of the application.
hostNameThe primary validated domain.The primary validated domain.
additionalTrustedOriginsEmpty or ignored.A list of secondary domains and subdomains.

For example, if your primary application runs on a subdomain but redirects users to a main corporate site or an identity provider, you must declare both. In the compiler configuration, your additionalTrustedOrigins array should include all secondary targets in full URI format, including the protocol scheme, such as https://auth.example.com or https://billing.example.com.

Deploying Digital Asset Links Across Web Origins

Setting up the Android configuration is only half the battle. Each external domain or subdomain listed in your additional trusted origins must reciprocate the trust relationship. This means you must host an identical assetlinks.json file on every origin.

If your setup includes three origins, you must ensure the verification file is reachable at these precise paths:

  • https://example.com/.well-known/assetlinks.json
  • https://app.example.com/.well-known/assetlinks.json
  • https://auth.example.com/.well-known/assetlinks.json

Each file must contain the exact same package name and the SHA-256 fingerprint of your Android app's signing key. If even one subdomain lacks this file, or if the server returns a 404 error, a redirect, or a CORS restriction that prevents Chrome from reading the file, navigating to that subdomain will trigger the display of the URL address bar.

Handling External Authentication and OAuth Providers

A frequent pain point for PWA developers is handling third-party sign-in options, such as logging in with Google, Apple, or GitHub. Because these providers do not allow you to host your application's assetlinks.json_ file on their secure servers, you cannot verify these origins inside your TWA container.

When a user initiates an OAuth flow, the browser must transition out of the immersive TWA container and open the authentication page in a Chrome Custom Tab. To handle this interaction cleanly without breaking the application user flow, developers should observe the following architectural practices:

  • Use redirection strategies that allow the login screen to be loaded inside a Custom Tab, which displays standard browser chrome during the external authentication step.
  • Ensure the authentication provider redirects back to your verified primary origin upon successful login. Once back on your verified origin, the TWA wrapper will automatically hide the URL bar again.
  • Where possible, utilize popups or web-based native credentials APIs to handle state synchronization, keeping the primary viewport on the validated application domain.

Verifying and Debugging Multi-Origin Setups

Debugging a multi-origin PWA requires verifying both the Android manifest declaration and the live web server configurations. Testing this layout manually on device emulators is straightforward using Android Debug Bridge (ADB) commands and Chrome Developer Tools.

First, connect your test device and launch Chrome DevTools. Inspect your TWA process while navigating across the declared subdomains. If the URL bar appears on a specific transition, Chrome's console logs or the system logcat will indicate why the validation failed. Often, this is due to an incorrectly formatted domain string, a missing protocol scheme, or a mismatch in the SHA-256 fingerprint listed in the remote JSON verification file.

You can force Chrome to bypass asset link verification for testing purposes by launching the browser with specific flags on your test device via the command line, allowing you to isolate wrapper bugs from server configuration issues. Once all domains validate successfully in the logs, you can build your release AAB and publish the updated version to the Google Play Store with full confidence that the URL bar will remain hidden across all of your domains.

Ready to ship your Android app?

Paste your PWA URL, get a signed APK and a Google Play ready AAB in minutes.

Build my app