Nullifying Precipitation Machine

    react-pwa-install-prompt
    TypeScript icon, indicating that this package has built-in type declarations

    1.0.5 • Public • Published

    react-pwa-install-prompt

    A react hook to prompt the install of your PWA in supported browsers (Chrome desktop & mobile)

    NPM JavaScript Style Guide

    Install

    yarn add react-pwa-install-prompt

    Usage

    import React from 'react'
    import usePWA from 'react-pwa-install-prompt'
     
    const Example = () => {
      const { isStandalone, isInstallPromptSupported, promptInstall } = usePWA()
     
     
      const onClickInstall = async () => {
        const didInstall = await promptInstall()
        if (didInstall) {
          // User accepted PWA install
        }
      }
     
    const renderInstallButton = () => {
        if (isInstallPromptSupported && isStandalone)
     
          return (
            <button onClick={onClickInstall}>Prompt PWA Install</button>
          )
        return null
      }
     
      return (<div>
        <h2>PWA Infos</h2>
        <p>Is Install Prompt Supported ? {isInstallPromptSupported ? 'true' : 'false'}</p>
        <p>Is Standalone ? {isStandalone ? 'true' : 'false'}</p>
        {renderInstallButton()}
      </div>)
    }
     
    export default Example
     

    License

    MIT © eric-edouard

    Keywords

    none

    Install

    npm i react-pwa-install-prompt

    DownloadsWeekly Downloads

    229

    Version

    1.0.5

    License

    MIT

    Unpacked Size

    18.6 kB

    Total Files

    9

    Last publish

    Collaborators

    • ericedouard