npm.io
1.0.0 • Published 6 years ago

use-install-prompt

Licence
ISC
Version
1.0.0
Deps
0
Size
4 kB
Vulns
0
Weekly
0
Stars
1

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)

Keywords