FilipChalupa / react-use-pwa-install

https://www.npmjs.com/package/react-use-pwa-install
ISC License
4 stars 0 forks source link
hook pwa react

react-use-pwa-install npm npm type definitions

Custom React hook for PWA install button.

Installation

npm install react-use-pwa-install

How to use

import { usePWAInstall } from 'react-use-pwa-install'

export const Header = () => {
    const install = usePWAInstall()

    return (
        <header>
            <h1>My app</h1>
            {install && <button onClick={install}>Install</button>}
        </header>
    )
}

Screencast

UI example

Demo

Check website or code.

Note

Don't forget to fulfill PWA requirements (web.dev, mdn) otherwise the usePWAInstall will return null. Same goes for already installed app.