Skip to content
Advertisement

PWA – How to hide button add to screen

I make react app from Create React App then use default config PWA. But i got confused how to hide button add to screen. Any one can help me? thank you enter image description here

Advertisement

Answer

You need to prevent the installation:

window.addEventListener('beforeinstallprompt', (e) => {
  e.preventDefault()
})

In addition you can save the installation event and create a custom install button:

let installEvent;
window.addEventListener('beforeinstallprompt', (e) => {
  e.preventDefault()
  installEvent = e;
})


button.onclick = () => {
   installEvent.prompt()
}
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement