demo · v139
Cross-Origin Storefront
The other side of the Web Install API: a storefront page installing someone else's PWA. Each card calls navigator.install(url) with a different origin and surfaces success/failure. Distinct from the self-install demo — this is the bookstore / curation / partner-store use case.
Cross-origin install requires the target site to opt in via its manifest and a user-activation gesture on this page. The API is under origin trial — enable via
chrome://flags/#enable-experimental-web-platform-features. The buttons below probe the real API; if unavailable, the log reports why.click a card to attempt install. Each card is a different cross-origin target.
the code
// 2-arg form: this site installs another site's PWA
async function installPartner(url, opts = {}) {
if (!('install' in navigator)) {
throw new Error('Web Install API unavailable. enable chrome://flags/#enable-experimental-web-platform-features');
}
const result = await navigator.install(url, opts);
// result.installed, result.icon, result.manifestId
return result;
}
button.addEventListener('click', async () => {
try {
await installPartner('https://example-pwa.dev/');
showSuccess();
} catch (e) {
// user dismissed, manifest missing, cross-origin not opted in, etc.
showError(e.name, e.message);
}
});