{"id":14990334,"url":"https://github.com/progressivewebcomponents/pwa-install","last_synced_at":"2025-04-12T02:10:24.148Z","repository":{"id":50022023,"uuid":"191541749","full_name":"ProgressiveWebComponents/pwa-install","owner":"ProgressiveWebComponents","description":"A tiny vanilla (zero-dependency) non-visual native browser web component (plug-n-play custom HTML element and extensible class) that helps implement custom patterns for promoting progressive web apps (PWA) installation","archived":false,"fork":false,"pushed_at":"2025-03-10T14:49:54.000Z","size":55,"stargazers_count":68,"open_issues_count":1,"forks_count":8,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-11T05:40:18.058Z","etag":null,"topics":["a2hs","api","custom-element","es-module","esm","floss","html-element","install","native","progressive-web-apps","pwa","tiny","trusted-web-activity","twa","vanilla","web","web-component","webapk","zero-dependencies","zero-dependency"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ProgressiveWebComponents.png","metadata":{"files":{"readme":"ReadMe.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-06-12T09:36:16.000Z","updated_at":"2025-03-10T14:49:06.000Z","dependencies_parsed_at":"2024-05-27T19:08:25.853Z","dependency_job_id":null,"html_url":"https://github.com/ProgressiveWebComponents/pwa-install","commit_stats":{"total_commits":3,"total_committers":1,"mean_commits":3.0,"dds":0.0,"last_synced_commit":"922a39eefce98bcb6416a5a47d2f4499d5591ef9"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ProgressiveWebComponents%2Fpwa-install","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ProgressiveWebComponents%2Fpwa-install/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ProgressiveWebComponents%2Fpwa-install/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ProgressiveWebComponents%2Fpwa-install/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ProgressiveWebComponents","download_url":"https://codeload.github.com/ProgressiveWebComponents/pwa-install/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248505929,"owners_count":21115354,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["a2hs","api","custom-element","es-module","esm","floss","html-element","install","native","progressive-web-apps","pwa","tiny","trusted-web-activity","twa","vanilla","web","web-component","webapk","zero-dependencies","zero-dependency"],"created_at":"2024-09-24T14:19:54.478Z","updated_at":"2025-04-12T02:10:24.117Z","avatar_url":"https://github.com/ProgressiveWebComponents.png","language":"JavaScript","readme":"[![Published on NPM](https://img.shields.io/npm/v/@progressivewebcomponents/pwa-install.svg)](https://npmjs.com/package/@progressivewebcomponents/pwa-install)\n[![Published on webcomponents.org](https://img.shields.io/badge/webcomponents.org-published-blue.svg)](https://webcomponents.org/element/@progressivewebcomponents/pwa-install)\n\nA tiny vanilla (zero-dependency) non-visual native browser web component (plug-n-play custom HTML element and extensible class) that helps implement [custom patterns for promoting progressive web apps (PWA) installation](https://web.dev/articles/promote-install).\n\nIt's compatible with [Google Polymer](https://polymer-library.polymer-project.org) library data binding.\n\n# Table of contents\n\n- [API](#api)\n  * [Methods](#methods)\n  * [Properties](#properties)\n  * [Attributes](#attributes)\n  * [Events](#events)\n- [Install](#install)\n- [Import](#import)\n  * [Local](#local)\n    + [JS](#js)\n    + [HTML](#html)\n    + [Import maps](#import-maps)\n      - [JS](#js-1)\n      - [HTML](#html-1)\n    + [Dev Servers / Builders](#dev-servers--builders)\n      - [JS](#js-2)\n      - [HTML](#html-2)\n  * [CDN](#cdn)\n    + [UNPKG](#unpkg)\n      - [JS](#js-3)\n      - [HTML](#html-3)\n    + [ESM CDN](#esm-cdn)\n      - [JS](#js-4)\n      - [HTML](#html-4)\n    + [Skypack](#skypack)\n      - [JS](#js-5)\n      - [HTML](#html-5)\n- [Use](#use)\n  * [HTML](#html-6)\n  * [JS](#js-6)\n  * [CSS](#css)\n  * [Lit](#lit)\n  * [Polymer](#polymer)\n- [Customize](#customize)\n- [Further reading](#further-reading)\n\n# API\n\n## Methods\n\n| Method                    | Type                   | Modifiers |\n|---------------------------|------------------------|-----------|\n| `prompt`                  | `(): ?Promise\u003cObject\u003e` | async     |\n| `getInstalledRelatedApps` | `(): ?Promise\u003cArray\u003e`  | async     |\n\n## Properties\n\n| Property                             | Type       | Modifiers |\n|--------------------------------------|------------|-----------|\n| `isInstallSupported`                 | `?boolean` | readonly  |\n| `isInstallAvailable`                 | `?boolean` | readonly  |\n| `platforms`                          | `?Array`   | readonly  |\n| `choiceResult`                       | `?Object`  | readonly  |\n| `isGetInstalledRelatedAppsSupported` | `?boolean` | readonly  |\n| `relatedApps`                        | `?Array`   | readonly  |\n\n## Attributes\n\n| Attribute                                 | Type       | Modifiers |\n|-------------------------------------------|------------|-----------|\n| `is-install-supported`                    | `?boolean` | readonly  |\n| `is-install-available`                    | `?boolean` | readonly  |\n| `is-get-installed-related-apps-supported` | `?boolean` | readonly  |\n\n## Events\n\n| Event                                             | Bubbles | Composed |\n|---------------------------------------------------|---------|----------|\n| `pwa-install-available`                           | true    | true     |\n| `pwa-install-installing`                          | true    | true     |\n| `pwa-install-installed`                           | true    | true     |\n| `pwa-install-error`                               | true    | true     |\n| `is-install-supported-changed`                    | false   | false    |\n| `is-install-available-changed`                    | false   | false    |\n| `platforms-changed`                               | false   | false    |\n| `choice-result-changed`                           | false   | false    |\n| `is-get-installed-related-apps-supported-changed` | false   | false    |\n| `related-apps-changed`                            | false   | false    |\n\n# Install\n\n```sh\nnpm i @progressivewebcomponents/pwa-install\n```\n\n# Import\n\n## Local\n\n### JS\n\n```js\nimport './node_modules/@progressivewebcomponents/pwa-install/pwa-install.js';\n```\n\n\u003cdetails\u003e\n  \u003csummary\u003eAdvanced usage\u003c/summary\u003e\n\n  See the [Customize](#customize) section for how to use the code below:\n\n  ```js\n  import { PWAInstall } from './node_modules/@progressivewebcomponents/pwa-install/pwa-install-class.js';\n  ```\n\u003c/details\u003e\n\n### HTML\n\n```html\n\u003cscript\n  type=\"module\"\n  src=\"./node_modules/@progressivewebcomponents/pwa-install/pwa-install.js\"\n\u003e\n\u003c/script\u003e\n```\n\n```html\n\u003cscript type=\"module\"\u003e\n  import './node_modules/@progressivewebcomponents/pwa-install/pwa-install.js';\n\u003c/script\u003e\n```\n\n\u003cdetails\u003e\n  \u003csummary\u003eAdvanced usage\u003c/summary\u003e\n\n  See the [Customize](#customize) section for how to use the code below:\n\n  ```html\n  \u003cscript type=\"module\"\u003e\n    import { PWAInstall } from './node_modules/@progressivewebcomponents/pwa-install/pwa-install-class.js';\n  \u003c/script\u003e\n  ```\n\u003c/details\u003e\n\n### Import maps\n\n```html\n\u003cscript type=\"importmap\"\u003e\n  {\n    \"imports\": {\n      \"pwa-install\": \"./node_modules/@progressivewebcomponents/pwa-install/pwa-install.js\",\n      \"pwa-install/\": \"./node_modules/@progressivewebcomponents/pwa-install/\"\n    }\n  }\n\u003c/script\u003e\n```\n\n#### JS\n\n```js\nimport 'pwa-install';\n```\n\n\u003cdetails\u003e\n  \u003csummary\u003eAdvanced usage\u003c/summary\u003e\n\n  See the [Customize](#customize) section for how to use the code below:\n\n  ```js\n  import { PWAInstall } from 'pwa-install/pwa-install-class.js';\n  ```\n\u003c/details\u003e\n\n#### HTML\n\n```html\n\u003cscript type=\"module\"\u003e\n  import 'pwa-install';\n\u003c/script\u003e\n```\n\n\u003cdetails\u003e\n  \u003csummary\u003eAdvanced usage\u003c/summary\u003e\n\n  See the [Customize](#customize) section for how to use the code below:\n\n  ```html\n  \u003cscript type=\"module\"\u003e\n    import { PWAInstall } from 'pwa-install/pwa-install-class.js';\n  \u003c/script\u003e\n  ```\n\u003c/details\u003e\n\n### Dev Servers / Builders\n\n#### JS\n\n```js\nimport '@progressivewebcomponents/pwa-install';\n```\n\n\u003cdetails\u003e\n  \u003csummary\u003eAdvanced usage\u003c/summary\u003e\n\n  See the [Customize](#customize) section for how to use the code below:\n\n  ```js\n  import { PWAInstall } from '@progressivewebcomponents/pwa-install/pwa-install-class.js';\n  ```\n\u003c/details\u003e\n\n#### HTML\n\n```html\n\u003cscript type=\"module\"\u003e\n  import '@progressivewebcomponents/pwa-install';\n\u003c/script\u003e\n```\n\n\u003cdetails\u003e\n  \u003csummary\u003eAdvanced usage\u003c/summary\u003e\n\n  See the [Customize](#customize) section for how to use the code below:\n\n  ```html\n  \u003cscript type=\"module\"\u003e\n    import { PWAInstall } from '@progressivewebcomponents/pwa-install/pwa-install-class.js';\n  \u003c/script\u003e\n  ```\n\u003c/details\u003e\n\n## CDN\n\n### UNPKG\n\n#### JS\n\n```js\nimport 'https://unpkg.com/@progressivewebcomponents/pwa-install';\n```\n\n\u003cdetails\u003e\n  \u003csummary\u003eAdvanced usage\u003c/summary\u003e\n\n  See the [Customize](#customize) section for how to use the code below:\n\n  ```js\n  import { PWAInstall } from 'https://unpkg.com/@progressivewebcomponents/pwa-install/pwa-install-class.js';\n  ```\n\u003c/details\u003e\n\n#### HTML\n\n```html\n\u003cscript\n  type=\"module\"\n  src=\"https://unpkg.com/@progressivewebcomponents/pwa-install\"\n\u003e\n\u003c/script\u003e\n```\n\n```html\n\u003cscript type=\"module\"\u003e\n  import 'https://unpkg.com/@progressivewebcomponents/pwa-install';\n\u003c/script\u003e\n```\n\n\u003cdetails\u003e\n  \u003csummary\u003eAdvanced usage\u003c/summary\u003e\n\n  See the [Customize](#customize) section for how to use the code below:\n\n  ```html\n  \u003cscript type=\"module\"\u003e\n    import { PWAInstall } from 'https://unpkg.com/@progressivewebcomponents/pwa-install/pwa-install-class.js';\n  \u003c/script\u003e\n  ```\n\u003c/details\u003e\n\n### ESM CDN\n\n#### JS\n\n```js\nimport 'https://esm.sh/@progressivewebcomponents/pwa-install';\n```\n\n\u003cdetails\u003e\n  \u003csummary\u003eAdvanced usage\u003c/summary\u003e\n\n  See the [Customize](#customize) section for how to use the code below:\n\n  ```js\n  import { PWAInstall } from 'https://esm.sh/@progressivewebcomponents/pwa-install/pwa-install-class.js';\n  ```\n\u003c/details\u003e\n\n#### HTML\n\n```html\n\u003cscript\n  type=\"module\"\n  src=\"https://esm.sh/@progressivewebcomponents/pwa-install\"\n\u003e\n\u003c/script\u003e\n```\n\n```html\n\u003cscript type=\"module\"\u003e\n  import 'https://esm.sh/@progressivewebcomponents/pwa-install';\n\u003c/script\u003e\n```\n\n\u003cdetails\u003e\n  \u003csummary\u003eAdvanced usage\u003c/summary\u003e\n\n  See the [Customize](#customize) section for how to use the code below:\n\n  ```html\n  \u003cscript type=\"module\"\u003e\n    import { PWAInstall } from 'https://esm.sh/@progressivewebcomponents/pwa-install/pwa-install-class.js';\n  \u003c/script\u003e\n  ```\n\u003c/details\u003e\n\n### Skypack\n\n#### JS\n\n```js\nimport 'https://cdn.skypack.dev/@progressivewebcomponents/pwa-install';\n```\n\n\u003cdetails\u003e\n  \u003csummary\u003eAdvanced usage\u003c/summary\u003e\n\n  See the [Customize](#customize) section for how to use the code below:\n\n  ```js\n  import { PWAInstall } from 'https://cdn.skypack.dev/@progressivewebcomponents/pwa-install/pwa-install-class.js';\n  ```\n\u003c/details\u003e\n\n#### HTML\n\n```html\n\u003cscript\n  type=\"module\"\n  src=\"https://cdn.skypack.dev/@progressivewebcomponents/pwa-install\"\n\u003e\n\u003c/script\u003e\n```\n\n```html\n\u003cscript type=\"module\"\u003e\n  import 'https://cdn.skypack.dev/@progressivewebcomponents/pwa-install';\n\u003c/script\u003e\n```\n\n\u003cdetails\u003e\n  \u003csummary\u003eAdvanced usage\u003c/summary\u003e\n\n  See the [Customize](#customize) section for how to use the code below:\n\n  ```html\n  \u003cscript type=\"module\"\u003e\n    import { PWAInstall } from 'https://cdn.skypack.dev/@progressivewebcomponents/pwa-install/pwa-install-class.js';\n  \u003c/script\u003e\n  ```\n\u003c/details\u003e\n\n# Use\n\n## HTML\n\n```html\n\u003cpwa-install id=\"a2hs\"\u003e\u003c/pwa-install\u003e\n```\n\n## JS\n\n```js\nconst pwaInstall = document.getElementById('a2hs');\n```\n\n```js\nconst choiseResult = await pwaInstall.prompt();\n\nconst relatedApps = await pwaInstall.getInstalledRelatedApps();\n```\n\n```js\nlet isInstallSupportedPropertyValue = pwaInstall.isInstallSupported;\n\nlet isInstallAvailablePropertyValue = pwaInstall.isInstallAvailable;\n\nlet platformsPropertyValue = pwaInstall.platforms;\n\nlet choiceResultPropertyValue = pwaInstall.choiceResult;\n\nlet isGetInstalledRelatedAppsSupportedPropertyValue = pwaInstall.isGetInstalledRelatedAppsSupported;\n\nlet relatedAppsPropertyValue = pwaInstall.relatedApps;\n```\n\n```js\nlet isInstallSupportedAttributeValue = pwaInstall.hasAttribute('is-install-supported');\n\nlet isInstallAvailableAttributeValue = pwaInstall.hasAttribute('is-install-available');\n\nlet isGetInstalledRelatedAppsSupportedAttributeValue = pwaInstall.hasAttribute('is-get-installed-related-apps-supported');\n```\n\n```js\npwaInstall.addEventListener('pwa-install-available', handlePWAInstallAvailableEvent);\n\npwaInstall.addEventListener('pwa-install-installing', handlePWAInstallInstallingEvent);\n\npwaInstall.addEventListener('pwa-install-installed', handlePWAInstallInstalledEvent);\n\npwaInstall.addEventListener('pwa-install-error', handlePWAInstallErrorEvent);\n```\n\n```js\nconst handlePWAInstallAvailableEvent = (event) =\u003e {\n  // Use event.detail.value and/or run any code\n}\n\nconst handlePWAInstallInstallingEvent = (event) =\u003e {\n  // Use event.detail.value and/or run any code\n}\n\nconst handlePWAInstallInstalledEvent = (event) =\u003e {\n  // Use event.detail.value and/or run any code\n}\n\nconst handlePWAInstallErrorEvent = (event) =\u003e {\n  // Use event.detail.message.error, event.detail.value and/or run any code\n}\n```\n\n\u003cdetails\u003e\n  \u003csummary\u003eUse case\u003c/summary\u003e\n\n  Events can be used to collect telemetry on (promoting) PWA installation and send it to e.g. Google Analytics:\n\n  ```js\n  const handlePWAInstallAvailableEvent = (event) =\u003e {\n    window.gtag?.('event', 'pwa-install', {\n      'state': 'available',\n      'platforms': event.detail.value,\n    });\n  }\n\n  const handlePWAInstallInstallingEvent = (event) =\u003e {\n    window.gtag?.('event', 'pwa-install', {\n      'state': 'installing',\n      'outcome': event.detail.value?.outcome,\n      'platform': event.detail.value?.platform,\n    });\n  }\n\n  const handlePWAInstallInstalledEvent = (event) =\u003e {\n    window.gtag?.('event', 'pwa-install', {\n      'state': 'installed',\n      'platform': event.detail.value?.platform,\n    });\n  }\n\n  const handlePWAInstallErrorEvent = (event) =\u003e {\n    window.gtag?.('event', 'pwa-install', {\n      'state': 'error',\n      'error': event.detail.message.error,\n      'platform': event.detail.value?.platform,\n    });\n  }\n  ```\n\u003c/details\u003e\n\n```js\npwaInstall.addEventListener('is-install-supported-changed', handleIsInstallSupportedPropertyChangedEvent);\n\npwaInstall.addEventListener('is-install-available-changed', handleIsInstallAvailablePropertyChangedEvent);\n\npwaInstall.addEventListener('platforms-changed', handlePlatformsPropertyChangedEvent);\n\npwaInstall.addEventListener('choice-result-changed', handleChoiceResultPropertyChangedEvent);\n\npwaInstall.addEventListener('is-get-installed-related-apps-supported-changed', handleIsGetInstalledRelatedAppsSupportedPropertyChangedEvent);\n\npwaInstall.addEventListener('related-apps-changed', handleRelatedAppsPropertyChangedEvent);\n```\n\n```js\nconst handleIsInstallSupportedPropertyChangedEvent = (event) =\u003e {\n  // Use event.detail.value and/or run any code\n}\n\nconst handleIsInstallAvailablePropertyChangedEvent = (event) =\u003e {\n  // Use event.detail.value and/or run any code\n}\n\nconst handlePlatformsPropertyChangedEvent = (event) =\u003e {\n  // Use event.detail.value and/or run any code\n}\n\nconst handleChoiceResultPropertyChangedEvent = (event) =\u003e {\n  // Use event.detail.value and/or run any code\n}\n\nconst handleIsGetInstalledRelatedAppsSupportedPropertyChangedEvent = (event) =\u003e {\n  // Use event.detail.value and/or run any code\n}\n\nconst handleRelatedAppsPropertyChangedEvent = (event) =\u003e {\n  // Use event.detail.value and/or run any code\n}\n```\n\n\u003cdetails\u003e\n  \u003csummary\u003eUse case\u003c/summary\u003e\n\n  Events can be used to update the property values:\n\n  ```js\n  const handleIsInstallSupportedPropertyChangedEvent = (event) =\u003e {\n    isInstallSupportedPropertyValue = event.detail.value;\n  }\n\n  const handleIsInstallAvailablePropertyChangedEvent = (event) =\u003e {\n    isInstallAvailablePropertyValue = event.detail.value;\n  }\n\n  const handlePlatformsPropertyChangedEvent = (event) =\u003e {\n    platformsPropertyValue = event.detail.value;\n  }\n\n  const handleChoiceResultPropertyChangedEvent = (event) =\u003e {\n    choiceResultPropertyValue = event.detail.value;\n  }\n\n  const handleIsGetInstalledRelatedAppsSupportedPropertyChangedEvent = (event) =\u003e {\n    isGetInstalledRelatedAppsSupportedPropertyValue = event.detail.value;\n  }\n\n  const handleRelatedAppsPropertyChangedEvent = (event) =\u003e {\n    relatedAppsPropertyValue = event.detail.value;\n  }\n  ```\n\u003c/details\u003e\n\n## CSS\n\n```css\n#a2hs[is-install-supported]\n\n#a2hs[is-install-available]\n\n#a2hs[is-get-installed-related-apps-supported]\n```\n\n\u003cdetails\u003e\n  \u003csummary\u003eUse case\u003c/summary\u003e\n\n  CSS attribute selectors can be used to show/hide and/or style other HTML elements e.g. the UI for promoting PWA installation:\n\n  ```html\n  \u003cpwa-install id=\"a2hs\"\u003e\u003c/pwa-install\u003e\n\n  \u003cbutton\n    id=\"install\"\n    onclick=\"document.getElementById('a2hs').prompt()\"\n  \u003e\n    Install\n  \u003c/button\u003e\n  ```\n\n  ```css\n  #install {\n    visibility: hidden;\n  }\n\n  :has(#a2hs[is-install-available]) #install {\n    visibility: visible;\n  }\n  ```\n\u003c/details\u003e\n\n## Lit\n\n```html\n\u003cpwa-install\n  id=\"a2hs\"\n\n  @pwa-install-available=\"${this.handlePWAInstallAvailableEvent}\"\n  @pwa-install-installing=\"${this.handlePWAInstallInstallingEvent}\"\n  @pwa-install-installed=\"${this.handlePWAInstallInstalledEvent}\"\n  @pwa-install-error=\"${this.handlePWAInstallErrorEvent}\"\n\n  @is-install-supported-changed=\"${this.handleIsInstallSupportedPropertyChangedEvent}\"\n  @is-install-available-changed=\"${this.handleIsInstallAvailablePropertyChangedEvent}\"\n  @platforms-changed=\"${this.handlePlatformsPropertyChangedEvent}\"\n  @choice-result-changed=\"${this.handleChoiceResultPropertyChangedEvent}\"\n  @is-get-installed-related-apps-supported-changed=\"${this.handleIsGetInstalledRelatedAppsSupportedPropertyChangedEvent}\"\n  @related-apps-changed=\"${this.handleRelatedAppsPropertyChangedEvent}\"\n\u003e\n\u003c/pwa-install\u003e\n```\n\n```js\nconst pwaInstall = this.shadowRoot.getElementById('a2hs');\n```\n\n## Polymer\n\n```html\n\u003cpwa-install\n  id=\"a2hs\"\n\n  is-install-supported=\"{{isInstallSupportedPropertyValue}}\"\n  is-install-available=\"{{isInstallAvailablePropertyValue}}\"\n  platforms=\"{{platformsPropertyValue}}\"\n  choice-result=\"{{choiceResultPropertyValue}}\"\n  is-get-installed-related-apps-supported=\"{{isGetInstalledRelatedAppsSupportedPropertyValue}}\"\n  related-apps=\"{{relatedAppsPropertyValue}}\"\n\n  on-pwa-install-available=\"handlePWAInstallAvailableEvent\"\n  on-pwa-install-installing=\"handlePWAInstallInstallingEvent\"\n  on-pwa-install-installed=\"handlePWAInstallInstalledEvent\"\n  on-pwa-install-error=\"handlePWAInstallErrorEvent\"\n\n  on-is-install-supported-changed=\"handleIsInstallSupportedPropertyChangedEvent\"\n  on-is-install-available-changed=\"handleIsInstallAvailablePropertyChangedEvent\"\n  on-platforms-changed=\"handlePlatformsPropertyChangedEvent\"\n  on-choice-result-changed=\"handleChoiceResultPropertyChangedEvent\"\n  on-is-get-installed-related-apps-supported-changed=\"handleIsGetInstalledRelatedAppsSupportedPropertyChangedEvent\"\n  on-related-apps-changed=\"handleRelatedAppsPropertyChangedEvent\"\n\u003e\n\u003c/pwa-install\u003e\n```\n\n```js\nconst pwaInstall = this.$.a2hs;\n```\n\n\u003cdetails\u003e\n  \u003csummary\u003eUse case\u003c/summary\u003e\n\n  Property values can be used to show/hide and/or change the state of other HTML elements e.g. the UI for promoting PWA installation:\n\n  ```html\n  \u003cpwa-install\n    id=\"a2hs\"\n    is-install-supported=\"{{isInstallSupportedPropertyValue}}\"\n    is-install-available=\"{{isInstallAvailablePropertyValue}}\"\n  \u003e\n  \u003c/pwa-install\u003e\n\n  \u003cbutton\n    on-click=\"handleInstallButtonClickEvent\"\n    hidden$=\"[[!isInstallSupportedPropertyValue]]\"\n    disabled$=\"[[!isInstallAvailablePropertyValue]]\"\n  \u003e\n    Install\n  \u003c/button\u003e\n  ```\n\n  ```js\n  handleInstallButtonClickEvent() {\n    this.$.a2hs.prompt();\n  }\n  ```\n\u003c/details\u003e\n\n# Customize\n\n`PWAInstall` class can be imported without registering `\u003cpwa-install\u003e` custom HTML element. It can be used to register the web component with a different custom HTML element name:\n\n```js\nimport { PWAInstall } from 'pwa-install/pwa-install-class.js';\n\ncustomElements.define('your-custom-element-name', PWAInstall);\n```\n\nor customize the web component:\n\n```js\nimport { PWAInstall } from 'pwa-install/pwa-install-class.js';\n\nclass YourCustomElement extends PWAInstall {\n  // Add or override methods, properties, attributes, events, etc.\n}\n\ncustomElements.define('your-custom-element-name', YourCustomElement);\n```\n\n```html\n\u003cyour-custom-element-name id=\"a2hs\"\u003e\u003c/your-custom-element-name\u003e\n```\n\n# Further reading\n\n[Patterns for promoting PWA installation](https://web.dev/articles/promote-install)\n\n[Native app install prompt](https://developer.chrome.com/blog/app-install-banners-native)\n\n[Is your app installed? `getInstalledRelatedApps()` will tell you!](https://web.dev/articles/get-installed-related-apps)\n\n[Detect if your native app is installed from your web site](https://medium.com/dev-channel/detect-if-your-native-app-is-installed-from-your-web-site-2e690b7cb6fb)\n\n[What does it take to be installable?](https://web.dev/articles/install-criteria)\n\n[Add a web app manifest](https://web.dev/articles/add-manifest)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprogressivewebcomponents%2Fpwa-install","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprogressivewebcomponents%2Fpwa-install","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprogressivewebcomponents%2Fpwa-install/lists"}