Bringing your PWA into the Play Store

Users increasingly look for apps in their operating system's store, and those who search for a specific brand or service often show higher engagement. For developers with a Progressive Web App (PWA), the Play Store represents a significant discovery channel. Trusted Web Activity (TWA) is an open standard that lets browsers render a full PWA inside an Android app, providing a path from the web to the Play Store.

TWA is available in Chrome since version 75 and is in development in Firefox Nightly.

Why not just use a WebView?

Prior solutions for embedding web content in Android apps came with trade-offs. While the Android WebView is suitable for web UI within an app, it is not a full browser engine. It lacks access to modern web platform features such as the contact picker or the File System Access API. Frameworks like Cordova attempted to address these gaps, but they do so by confining you to their own APIs, creating a separate codebase from your open-web PWA.

These approaches also introduce compatibility risks across Android versions and OEM implementations, adding quality assurance overhead to develop and maintain workarounds.

A standards-based container for web apps

TWA leverages the underlying browser to render the PWA in full screen, which means it gets the same compatibility with web platform features as the browser itself. A notable benefit over previous methods is shared storage: login states and user preferences are consistent between the browser and the TWA experience.

Open-source tooling exists to simplify building an Android app with TWA. Google's Bubblewrap and PWABuilder provide a library, CLI, and GUI respectively, so web developers can package their PWA without learning new, Android-specific technologies.

TWA Project setup

Bootstrapping a new project with Bubblewrap is a matter of pointing the CLI at your Web Manifest:

bubblewrap init --manifest=https://example.com/manifest.json

Building the project for release is equally direct:

bubblewrap build

The output of this command is app-release-signed.apk, which you can upload directly to the Play Store. PWABuilder wraps this process in a graphical interface and can transform an existing site into a PWA as well.

Meeting quality and ownership criteria

Not all web content qualifies for TWA. Web content must meet the PWA installability criteria. Additionally, starting with Chrome 86, scenarios that were previously just errors are now treated as crashes of the Android app, causing a user-visible failure. These include:

  • Failing to verify Digital Asset Links at app launch.
  • Failing to return an HTTP 200 for an offline network resource request.
  • A navigation request that returns an HTTP 404 or 5xx error.

Handling these scenarios in your service worker is critical. Android-specific policy compliance also applies.

Establishing app ownership

To prevent unauthorized wrapping of a PWA, the Android app is paired with the web app through Digital Asset Links. Bubblewrap and PWABuilder handle the Android-side configuration, but you must publish an assetlinks.json file in the PWA's domain.

To generate that file, you need the SHA-256 signature of the key that signs the APK users download. For a correct signature, the most reliable approach is to deploy the app to a closed test channel on the Play Store, install it on a test device, and use tools like Peter's Asset Link Tool to generate the correct assetlinks.json. Place that generated file at /.well-known/assetlinks.json on the domain being validated.

Next steps for deployment

For those with an existing PWA, Lighthouse is the tool to verify it meets quality criteria before proceeding to package it with Bubblewrap or PWABuilder. After wrapping the app, upload it to the closed test channel, pair it with your PWA via the asset links, and only then promote the new Android app to the production channel once everything checks out.