Installed app
Manifest, icons and splash screens, adapting the UI when installed, the install prompt, keeping state, badges and sharing.
Installing is what makes the disguise work: the app gets a home-screen icon, a launch screen and a window without the browser's address bar and buttons. It also takes things away that the browser used to provide — a back button, reload, the URL, and on iOS even the user's logged-in session. This page covers both halves.
No live demos here: installing needs a manifest, and this site isn't an app.
Manifest
import type { MetadataRoute } from "next";
export const dynamic = "force-static";
export default function manifest(): MetadataRoute.Manifest {
return {
id: "/",
name: "Acme Orders",
short_name: "Orders",
start_url: "/",
display: "standalone",
background_color: "#ffffff",
theme_color: "#ffffff",
icons: [
{ src: "/pwa-192x192.png", sizes: "192x192", type: "image/png" },
{ src: "/pwa-512x512.png", sizes: "512x512", type: "image/png" },
{
src: "/maskable-icon-512x512.png",
sizes: "512x512",
type: "image/png",
purpose: "maskable",
},
],
};
}short_nameis the label under the home-screen icon; keep it short enough not to be truncated.background_colorfills the launch screen on Android, so match the app's first paint.display: "standalone"is the one to use. iOS doesn't supportminimal-ui(falls back to a browser tab) orfullscreen(falls back to standalone).dynamic = "force-static"is foroutput: "export"; a server-rendered app doesn't need it.
Icons and splash screens
| Asset | Used by | Notes |
|---|---|---|
192 and 512 px PNG, purpose: "any" | Android, desktop install | transparent background is fine |
512 px PNG, purpose: "maskable" | Android adaptive icons | opaque background; content inside a central circle 80% of the width |
apple-touch-icon, 180 px | iOS home screen | overrides the manifest icons on iOS when present |
apple-touch-startup-image, one per device | iOS launch screen | the only way to get one on iOS |
favicon.ico, SVG icon | browser tabs | not part of the installed app |
Don't make one icon both any and maskable: the padding a maskable icon
needs makes the regular one look shrunken. iOS ignores maskable and
monochrome, and only uses SVG icons from the manifest, since iOS 26.
Generating them
Draw one square SVG (design for 1024 px or larger) and generate the PNGs.
@vite-pwa/assets-generator works without Vite and needs no browser — it
uses sharp:
pnpm add -D @vite-pwa/assets-generator
pnpm pwa-assets-generator --preset minimal-2023 public/logo.svgThe minimal-2023 preset writes the 64, 192 and 512 px icons, a 512 px
maskable icon, a 180 px apple-touch-icon and favicon.ico, with more
padding on the maskable and Apple icons than on the regular ones. It can
also generate iOS launch screens per device, in light and dark versions,
through its config file. Commit the output; the icons change rarely.
pwa-asset-generator is the alternative when you want the launch screen to
be an HTML page rendered by Chrome (it uses Puppeteer) or want it to rewrite
your manifest and HTML. RealFaviconGenerator does the same in a web UI.
Check the maskable icon before shipping: maskable.app previews it under every mask shape, and Chrome DevTools → Application → Manifest has a "show only the minimum safe area" toggle.
iOS tags in Next.js
import type { Metadata } from "next";
export const metadata: Metadata = {
appleWebApp: {
title: "Orders",
statusBarStyle: "default",
startupImage: [
{
url: "/apple-splash-portrait-1179x2556.png",
media:
"(device-width: 393px) and (device-height: 852px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)",
},
],
},
other: {
"apple-mobile-web-app-capable": "yes",
},
};The other entry is not a leftover. Since 2024, Next.js's
appleWebApp.capable emits mobile-web-app-capable instead of the
apple--prefixed tag (#70363),
but iOS shows startup images only when apple-mobile-web-app-capable is
present (#74524). The
generator prints the startupImage list for the devices you pick.
statusBarStyle: "black-translucent" is the only way to draw under the
status bar; pair it with the safe-area insets from Basics.
Adapting the UI when installed
The display-mode media query tells you whether the app runs installed:
@media (display-mode: standalone) {
.install-button {
display: none;
}
}import * as React from "react";
const query = "(display-mode: standalone)";
function subscribe(onChange: () => void) {
const media = window.matchMedia(query);
media.addEventListener("change", onChange);
return () => media.removeEventListener("change", onChange);
}
export function useIsInstalled() {
return React.useSyncExternalStore(
subscribe,
() => window.matchMedia(query).matches,
() => false,
);
}What changes once the browser chrome is gone:
- Back. There's no browser back button. Android still has its system back; on iOS, put a back button in the app's own header.
- Reload. Nothing to pull or press if you turned off pull-to-refresh (Overscroll) — give screens that can go stale their own refresh.
- The URL. People can't copy a link to what they see. A share button (below) replaces it.
- Sign-in on iOS. An app installed from Safari doesn't share storage with Safari, so the user starts logged out. Expect a sign-in right after install, and keep it short — passkeys and password autofill help.
navigator.standalone is the old iOS-only way to detect this; the media
query replaces it.
Install prompt
Only Chromium browsers let a page trigger installation, through the
non-standard beforeinstallprompt event. Keep the event, show your own
button, and call prompt() from the click — once per event:
let deferred: BeforeInstallPromptEvent | null = null;
window.addEventListener("beforeinstallprompt", (event) => {
event.preventDefault();
deferred = event as BeforeInstallPromptEvent;
installButton.hidden = false;
});
installButton.addEventListener("click", async () => {
if (!deferred) return;
await deferred.prompt();
deferred = null;
installButton.hidden = true;
});
window.addEventListener("appinstalled", () => {
installButton.hidden = true;
});The event has no standard type, so declare BeforeInstallPromptEvent
yourself. Hide the button by default: the event doesn't fire in browsers
without the API, nor when the app is already installed. Listen for
appinstalled too, since people can still install from the browser menu.
iOS has no prompt and no API. The only route is Share → Add to Home Screen, so the common pattern is a one-time hint in Safari explaining those two taps, hidden in standalone mode and after it's dismissed. Since iOS 26, any site added to the Home Screen opens as a web app, manifest or not.
Keeping state
Browsers freeze or discard background pages to save resources, and an
installed app that the system closes starts fresh from start_url on the
next launch. Native apps reopen where you left them, so save as you go:
document.addEventListener("visibilitychange", () => {
if (document.visibilityState === "hidden") {
localStorage.setItem(
"resume",
JSON.stringify({ path: location.pathname, scrollY: window.scrollY }),
);
}
});MDN calls the switch to hidden "the last event that's reliably observable
by the page", so save there rather than on unload. Use localStorage, not
sessionStorage: a fresh launch is a new session, and sessionStorage
starts empty. On load, read it back and navigate before the first paint.
Chrome also exposes document.wasDiscarded, true when the page was reloaded
after being discarded. Drafts belong in localStorage or IndexedDB too, saved
on input rather than on hide.
Badges and sharing
navigator.setAppBadge?.(unreadCount);
navigator.clearAppBadge?.();The Badging API puts a count on the app icon and only works for installed apps. On iOS (16.4+) the count shows only after the user grants notification permission, the same as for native apps.
button.addEventListener("click", async () => {
const data = { title: order.title, url: order.url };
if (navigator.canShare?.(data)) await navigator.share(data);
});navigator.share opens the system share sheet. It needs HTTPS and a user
gesture, and can share text, URLs and files. In an installed app it's how
people get a link out, since there's no address bar.
The reverse — appearing in other apps' share sheets — is the manifest's
share_target. It works only for installed apps and not on iOS.
Sources
- MDN:
manifest
icons, Define your app icons,display-mode, Trigger install prompt,visibilitychange, Badging API,navigator.share,share_target - web.dev, Adaptive icon support in PWAs with maskable icons
- Chrome for Developers, Page Lifecycle API
- WebKit, Web Push for Web Apps on iOS and iPadOS (2023)
- Maximiliano Firtman, PWA iOS compatibility notes
- Next.js: app icons, manifest
- Tools:
@vite-pwa/assets-generator,pwa-asset-generator, RealFaviconGenerator, maskable.app
Basics
The handful of CSS lines that stop a web app from feeling like a web page on a phone — zoom, text selection, long press, tap highlight, overscroll, scrollbars, viewport height and safe areas.
Motion
Interruptible animations and springs — why native motion feels physical, and how to get the same on the web with CSS transitions, linear() and a small spring.