Search code examples
reactjsprogressive-web-appsdeep-linking

How to open PWA from a button within the web-app?


I want to add a button to my React Web App that opens our PWA.

I was able to get the "Install" dialog to open by caching the "beforeinstallprompt" event and triggering it with a button but now I'm looking for a way to open the "Open with" dialog in chrome that allows the user to launch the (already installed) PWA, or open the PWA itself on the click of the button within the app but I'm unable to find any resources.


Solution

  • There is a way to do this, you could do the following:

    <a href='https://myappurl.com' target='_blank'>Open PWA</a>

    The target='_blank' is important, also the url specified in the href attribute needs to be the same as the one specified in the scope, if the scope is "." then any url within your app will open the PWA, this will work in Android with Chrome browser, I haven't tested this on iPhone.