{"id":18569039,"url":"https://github.com/filipchalupa/pwa-install-handler","last_synced_at":"2025-04-10T06:31:53.748Z","repository":{"id":57332126,"uuid":"170128742","full_name":"FilipChalupa/pwa-install-handler","owner":"FilipChalupa","description":"Handling PWA installation prompt made easier. ","archived":false,"fork":false,"pushed_at":"2024-12-10T13:11:47.000Z","size":451,"stargazers_count":11,"open_issues_count":5,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-24T16:55:25.524Z","etag":null,"topics":["addtohomescreen","installation","npm","pwa","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/pwa-install-handler","language":"TypeScript","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/FilipChalupa.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-02-11T12:56:44.000Z","updated_at":"2025-01-08T08:05:29.000Z","dependencies_parsed_at":"2024-11-06T22:36:25.672Z","dependency_job_id":"c7716459-7876-4325-bb5a-49b7d099f6c4","html_url":"https://github.com/FilipChalupa/pwa-install-handler","commit_stats":{"total_commits":67,"total_committers":1,"mean_commits":67.0,"dds":0.0,"last_synced_commit":"d048cc587d68d9727ba8e1728f882e67eccdc9cc"},"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FilipChalupa%2Fpwa-install-handler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FilipChalupa%2Fpwa-install-handler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FilipChalupa%2Fpwa-install-handler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FilipChalupa%2Fpwa-install-handler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FilipChalupa","download_url":"https://codeload.github.com/FilipChalupa/pwa-install-handler/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248168273,"owners_count":21058803,"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":["addtohomescreen","installation","npm","pwa","typescript"],"created_at":"2024-11-06T22:31:53.659Z","updated_at":"2025-04-10T06:31:53.723Z","avatar_url":"https://github.com/FilipChalupa.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PWA install handler\n\nHandling PWA installation prompt made easier. [MDN docs](https://developer.mozilla.org/en-US/docs/Web/API/Window/onbeforeinstallprompt)\n\n## Installation\n\n```sh\nnpm install pwa-install-handler\n```\n\n## Usage\n\n### HTML\n\n```html\n\u003cbutton id=\"installButton\" style=\"display: none;\"\u003eInstall\u003c/button\u003e\n```\n\n### JavaScript\n\n```javascript\nimport { pwaInstallHandler } from 'pwa-install-handler'\n\nconst $button = document.querySelector('#installButton')\n\npwaInstallHandler.addListener((canInstall) =\u003e {\n\t$button.style.display = canInstall ? 'inline-block' : 'none'\n})\n\n$button.addEventListener('click', () =\u003e {\n\tpwaInstallHandler.install()\n})\n```\n\n### React\n\nFor more information see [react-use-pwa-install](https://www.npmjs.com/package/react-use-pwa-install).\n\n### Screencast\n\n![UI example](https://raw.githubusercontent.com/FilipChalupa/pwa-install-handler/HEAD/screencast.gif)\n\n### Demo\n\nCheck [website](https://filipchalupa.cz/pwa-install-handler/) or [code](https://github.com/FilipChalupa/pwa-install-handler/tree/main/demo).\n\n## Methods\n\n```typescript\npwaInstallHandler.install: () =\u003e Promise\u003cboolean\u003e\n```\n\n```typescript\npwaInstallHandler.addListener: (\n\tcallback: (canInstall: boolean, install?: () =\u003e Promise\u003cboolean\u003e) =\u003e void,\n) =\u003e void\n```\n\n```typescript\npwaInstallHandler.removeListener: (\n\tcallback: (canInstall: boolean, install?: () =\u003e Promise\u003cboolean\u003e) =\u003e void,\n) =\u003e void\n```\n\n```typescript\npwaInstallHandler.canInstall: () =\u003e boolean\n```\n\n```typescript\npwaInstallHandler.getEvent: () =\u003e BeforeInstallPromptEvent | null\n```\n\n## Notes\n\nYou PWA must meet some requirements to be installable. Without that the `canInstall` will always be `false`. The requirements are browser specific. You can read more about it [here (MDN)](https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps/Installable_PWAs#Requirements) and [here (web.dev)](https://web.dev/install-criteria/).\n\nSome browsers don't support custom install button. These will have `canInstall` always set to `false` too. For more information check [BeforeInstallPromptEvent support](https://caniuse.com/#feat=mdn-api_beforeinstallpromptevent).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffilipchalupa%2Fpwa-install-handler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffilipchalupa%2Fpwa-install-handler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffilipchalupa%2Fpwa-install-handler/lists"}