JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 914
  • Score
    100M100P100Q110811F
  • License ISC

Custom React hook for PWA install button.

Package Exports

  • react-use-pwa-install
  • react-use-pwa-install/dist/index.es.js
  • react-use-pwa-install/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-use-pwa-install) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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 React from 'react'
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>
    )
}

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

Screencast

UI example

Note

Don't forget to fulfill other PWA requirements (webmanifest, service worker, supported browser). Your webapp must be installable otherwise the install button won't show.