Socket
Socket
Sign inDemoInstall

react-pwa-install-prompt

Package Overview
Dependencies
6
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-pwa-install-prompt

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


Version published
Weekly downloads
164
decreased by-21.9%
Maintainers
1
Install size
18.1 kB
Created
Weekly downloads
 

Readme

Source

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

FAQs

Last updated on 04 Oct 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc