1.0.0 • Published 4 years ago

use-install-prompt v1.0.0

Weekly downloads
2
License
ISC
Repository
github
Last release
4 years ago

useInstallPrompt ⚛️

A hook for accessing Google Chrome's Install button for PWAs.

npm.io

npm.io

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)