use-install-prompt
v1.0.0
Published
> A hook for accessing Google Chrome's [Install](https://developer.mozilla.org/en-US/docs/Web/API/BeforeInstallPromptEvent) button for PWAs.
Downloads
38
Readme
useInstallPrompt ⚛️
A hook for accessing Google Chrome's Install button for PWAs.
Install
npm i use-install-prompt
Usage
import React from "react"
import useInstallPrompt from "use-install-prompt"
const App: React.FC = () => {
const [prompt, promptToInstall] = useInstallPrompt()
return prompt ? (
<button onClick={promptToInstall} />
) : (
<h1>Browser not supported.</h1>
)
}
Call promptToInstall
to show the install prompt in Chrome.
Check if prompt
is defined to deside whether to show a button or not. (On a supported browser)