Skip to content

Show "Install App" prompt for PWA installation 📱 #504

Description

@anoopcodehack

Show "Install App" prompt for PWA installation 📱

File: client/src/pages/Dashboard.jsx

PWA manifest exists but no install
prompt shown to users 💀 fr!!

Fix: capture beforeinstallprompt event:
const [installPrompt, setInstallPrompt] = useState(null)

useEffect(() => {
window.addEventListener('beforeinstallprompt', (e) => {
e.preventDefault()
setInstallPrompt(e)
})
}, [])

const handleInstall = async () => {
if (!installPrompt) return
await installPrompt.prompt()
setInstallPrompt(null)
}

{installPrompt && (

📱 Install App

)}

~15 lines! PWA manifest already added ✅
No backend needed 🎯

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions