1.0.5 • Published 4 years ago

react-pwa-install-prompt v1.0.5

Weekly downloads
26
License
MIT
Repository
github
Last release
4 years ago

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

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.0

4 years ago