2.0.6 • Published 11 months ago

react-ios-pwa-prompt v2.0.6

Weekly downloads
2,426
License
-
Repository
github
Last release
11 months ago

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

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

  2. Import into your project:

import PWAPrompt from 'react-ios-pwa-prompt'
  1. Render the component:
<PWAPrompt />
  1. 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" />
  1. 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} />
)
2.0.3

11 months ago

2.0.2

11 months ago

2.0.5

11 months ago

2.0.4

11 months ago

2.0.6

11 months ago

2.0.1

11 months ago

2.0.0

11 months ago

1.8.4

5 years ago

1.8.3

5 years ago

1.8.2

5 years ago

1.8.1

5 years ago

1.8.0

5 years ago

1.7.0

5 years ago

1.6.0

5 years ago

1.5.1

5 years ago

1.5.0

6 years ago

1.4.3

6 years ago

1.4.2

6 years ago

1.4.1

6 years ago

1.4.0

6 years ago

1.3.1

6 years ago

1.3.0

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago