Skip to content

Instantly share code, notes, and snippets.

@ulrischa
Forked from adactio/ButtonInstall.js
Created November 29, 2025 19:17
Show Gist options
  • Select an option

  • Save ulrischa/71963333b3dc12c93088ae9ecd8a2c73 to your computer and use it in GitHub Desktop.

Select an option

Save ulrischa/71963333b3dc12c93088ae9ecd8a2c73 to your computer and use it in GitHub Desktop.
Web Install HTML web component
class ButtonInstall extends HTMLElement {
connectedCallback () {
this.button = this.querySelector('button');
if (window.matchMedia('(display-mode: standalone)').matches) {
this.button.remove();
return;
}
if (!navigator.install) {
this.button.remove();
return;
}
this.button.addEventListener('click', async (ev) => {
await navigator.install();
});
}
}
customElements.define('button-install', ButtonInstall);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment