2.6.2 • Published 11 months ago
pwa-install-handler v2.6.2
PWA install handler
Handling PWA installation prompt made easier. MDN docs
Installation
npm install pwa-install-handlerUsage
HTML
<button id="installButton" style="display: none;">Install</button>JavaScript
import { pwaInstallHandler } from 'pwa-install-handler'
const $button = document.querySelector('#installButton')
pwaInstallHandler.addListener((canInstall) => {
$button.style.display = canInstall ? 'inline-block' : 'none'
})
$button.addEventListener('click', () => {
pwaInstallHandler.install()
})React
For more information see react-use-pwa-install.
Screencast

Demo
Methods
pwaInstallHandler.install: () => Promise<boolean>pwaInstallHandler.addListener: (
callback: (canInstall: boolean, install?: () => Promise<boolean>) => void,
) => voidpwaInstallHandler.removeListener: (
callback: (canInstall: boolean, install?: () => Promise<boolean>) => void,
) => voidpwaInstallHandler.canInstall: () => booleanpwaInstallHandler.getEvent: () => BeforeInstallPromptEvent | nullNotes
You 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) and here (web.dev).
Some browsers don't support custom install button. These will have canInstall always set to false too. For more information check BeforeInstallPromptEvent support.
2.6.2
11 months ago
2.6.1
1 year ago
2.6.0
1 year ago
2.5.0
2 years ago
2.3.0
3 years ago
2.4.0
3 years ago
2.2.0
3 years ago
2.1.6
5 years ago
2.1.5
5 years ago
2.1.4
5 years ago
2.1.3
5 years ago
2.1.2
5 years ago
2.1.1
5 years ago
2.1.0
5 years ago
2.0.7
6 years ago
2.0.6
6 years ago
2.0.5
7 years ago
2.0.4
7 years ago
2.0.3
7 years ago
2.0.2
7 years ago
2.0.1
7 years ago
1.0.0
7 years ago