🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

react-ios-pwa-prompt

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-ios-pwa-prompt

A React component to prompt the user to add the app as a PWA to the home screen with native iOS styles.

2.0.6
latest
Source
npm
Version published
Weekly downloads
6.3K
9.26%
Maintainers
1
Weekly downloads
 
Created
Source

React-iOS-PWA-prompt

npm version Gzip file size

Polyfilling PWAs for iOS

A React component that provides a customisable Progressive Web App (PWA) prompt telling the user to 'Add to Home Screen'. The prompt behaviour is baked in to Android devices, yet iOS is still lagging behind. This component aims to provide a simple way to provide this functionality on iOS for websites that are PWA-ready. The prompt styles closely match iOS designs for both light and dark UI modes to appear native to the user.

Features

  • 🛠 Fully configurable, set how many times you want to see it, and after how many page visits.
  • 📃 PWA available offline? In full screen mode? Customise the content of your prompts message through props.
  • ⚡️ Efficient. Very little overhead for non-iOS devices and does as little work as needed for each page load.
  • 🌕 Light & dark mode available depending on user's settings.

Usage

  • Add react-ios-pwa-prompt as a dependency using pnpm add react-ios-pwa-prompt.

  • Import into your project:

import PWAPrompt from 'react-ios-pwa-prompt'
  • Render the component:
<PWAPrompt />
  • Add optional props to configure:
PropDescriptionDefault Value
timesToShowNumber of consecutive visits to show the prompt2
promptOnVisitOn which visit should the first prompt be shown?2
delayPass an integer in ms to add a delay to the prompt1000
onCloseCallback function for once the prompt is dismisseed() => undefined
copyTitleThe title of the promptAdd to Home Screen
copySubtitleThe subtitle of the promptString(window.location.href)
copyDescriptionThe description of the promptThis website has app functionality. Add it to your home screen to use it in fullscreen and while offline.
copyShareStepThe Share button copyPress the 'Share' button on the menu bar below
copyAddToHomescreenStepThe Add To Homescreen button copyPress 'Add to Home Screen'
appIconPathPath to an icon or favicon to be shown as the app iconhttps://s2.googleusercontent.com/s2/favicons?domain=${window.location.origin}
isShownCan be set to true to manually show the promptundefined
<PWAPrompt promptOnVisit={1} timesToShow={1} copyClosePrompt="Close" />
  • Create your own trigger rules You can easily set your own trigger conditions if you don't like the consecutive page loads approach. For example:
const [shouldShowPWAPrompt, setShouldShowPWAPrompt] = useState(false)

useEffect(() => {
    // 20% chance of popping up
    setShouldShowPWAPrompt(Math.random() < 0.2)
}, [])

return (
    <PWAPrompt isShown={shouldShowPWAPrompt} />
)

Keywords

pwa

FAQs

Package last updated on 22 Jul 2024

Did you know?

Socket

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