From Progressive Web App to Android AAB: Packaging Modern AI Assistants with Capacitor
How to share one responsive React codebase across desktop web browsers, installable PWAs, and Google Play Android App Bundles.
By Arush Rawat (Founder & Lead Systems Engineer, RAWMEN STUDIOS)
One Unified Frontend Across Web, PWA, and Android WebView
Maintaining separate Android Kotlin and desktop React codebases doubles engineering effort and slows every feature release. Combining a responsive Vite + React Progressive Web App with Capacitor lets teams wrap the exact same compiled `dist/` bundle inside a native Android shell capable of producing signed `.aab` releases while continuing to serve desktop browsers over HTTPS.
Success depends on handling two platform boundary differences cleanly: API origin routing when running inside `capacitor://` or `file://` protocols, and safe viewport spacing (`env(safe-area-inset-top)`) around mobile display notches.
Service Worker Caching Without Stale Deployments
A poorly configured Service Worker is the #1 cause of users seeing yesterday's broken JavaScript after you deploy a critical fix. Use a **network-first** strategy for HTML navigation documents (`req.mode === 'navigate'`) so users always receive fresh asset hashes whenever online, while reserving stale-while-revalidate caching strictly for fingerprinted static JS, CSS, and icon files.
Whenever you ship structural route updates, increment the cache version constant (e.g., `dravis-asi-v12`) and purge obsolete caches during the Service Worker `activate` lifecycle event.
Key Takeaways
- Capacitor packages a standard Vite dist/ build into a native Android WebView without rewriting UI.
- Always use network-first caching for navigation HTML documents in Service Workers.
- Bump the PWA cache key on major builds so returning clients load fresh assets immediately.