
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
react-ios-pwa-prompt
Advanced tools
A React component to prompt the user to add the app as a PWA to the home screen with native iOS styles.
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.
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'
<PWAPrompt />
Prop | Description | Default Value |
---|---|---|
timesToShow | Number of consecutive visits to show the prompt | 2 |
promptOnVisit | On which visit should the first prompt be shown? | 2 |
delay | Pass an integer in ms to add a delay to the prompt | 1000 |
onClose | Callback function for once the prompt is dismisseed | () => undefined |
copyTitle | The title of the prompt | Add to Home Screen |
copySubtitle | The subtitle of the prompt | String(window.location.href) |
copyDescription | The description of the prompt | This website has app functionality. Add it to your home screen to use it in fullscreen and while offline. |
copyShareStep | The Share button copy | Press the 'Share' button on the menu bar below |
copyAddToHomescreenStep | The Add To Homescreen button copy | Press 'Add to Home Screen' |
appIconPath | Path to an icon or favicon to be shown as the app icon | https://s2.googleusercontent.com/s2/favicons?domain=${window.location.origin} |
isShown | Can be set to true to manually show the prompt | undefined |
<PWAPrompt promptOnVisit={1} timesToShow={1} copyClosePrompt="Close" />
const [shouldShowPWAPrompt, setShouldShowPWAPrompt] = useState(false)
useEffect(() => {
// 20% chance of popping up
setShouldShowPWAPrompt(Math.random() < 0.2)
}, [])
return (
<PWAPrompt isShown={shouldShowPWAPrompt} />
)
FAQs
A React component to prompt the user to add the app as a PWA to the home screen with native iOS styles.
The npm package react-ios-pwa-prompt receives a total of 6,086 weekly downloads. As such, react-ios-pwa-prompt popularity was classified as popular.
We found that react-ios-pwa-prompt demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.