Adding a PWA Shortcut to the Desktop
We wanted users to “install” the WebShell as a desktop app. The plan: implement PWA support and leverage the add-to-home-screen experience.
PWA Configuration
manifest.webmanifest
display
minimal-ui
standalone
name
/short_name
/display
- Changing
name
shows an update prompt after a browser restart;display
applies immediately without a prompt.
- Changing
description
- Shows on Windows when you hover over the shortcut—keep it short.
- Updating the manifest doesn’t refresh existing shortcuts; users must reinstall.
theme_color
Update it dynamically via <meta name="theme-color" content="#0066ff"/>
if needed.
icons
- Provide 192px/512px sizes; include maskable variants.
screenshots
- Recommended sizes:
400x822
(narrow) and1280x676
(wide). - Use PNG; WebP didn’t work in our tests.
- Recommended sizes:
Register the Service Worker
Debugging
Chrome incognito disables install prompts and Service Worker logging.
Compatibility
Most modern browsers support PWAs (Firefox, Safari, etc.), though install support varies. Desktop installation works on recent Edge/Chrome releases for Windows and macOS.
Listen for beforeinstallprompt
; if it fires, installation is available.
window.addEventListener('beforeinstallprompt', (e) => {
// Non-null means installation is available; null means unsupported or already installed.
window.deferredPrompt = e;
});
Some Chrome users still reported no prompt—likely due to browser settings. The approach above plus beforeinstallprompt
gets us most of the way there.
Update: Safari on macOS Sonoma now shows installation prompts.
Common Questions
Detecting standalone launch:
function isStandalone() { if (window.matchMedia('(display-mode: standalone)').matches || ('standalone' in navigator && (navigator.standalone === true))) { return true; } return false; }
Detect whether the app is already installed
beforeinstallprompt
won’t fire if it’s unsupported (Firefox), prerequisites aren’t met, or it’s already installed. There’s no perfect detection.
Programmatically open the installed app from the webpage? No API yet.
Multiple launches
- Each “Open with” click opens another window; PWAs are still browser tabs under the hood.
Custom install prompt
- You can add your own UI and trigger the browser’s prompt manually:
installApp.addEventListener('click', async () => { if (deferredPrompt !== null) { deferredPrompt.prompt(); const {outcome} = await deferredPrompt.userChoice; if (outcome === 'accepted') { window.deferredPrompt = null; } } });
Splash screens? Not configurable beyond what the browser provides—simulate it with your own loading animation.
Incognito mode won’t trigger
beforeinstallprompt
, though Service Workers still run.HTTPS is mandatory for PWAs.
Example Sites
Examples that support desktop install:
Closing Thoughts
This setup focuses on one PWA feature—adding a desktop entry point.