-
Following up on the Discord discussion here: https://discord.com/channels/770287896669978684/1136740580626542683/1164272621177819168 I was wondering if there's a way to set the default url of a newly installed pwa? So let's say i click "Install" on "/app", this will prompt my browse to close the existing window and open the "/app" page on installed pwa. One PWA I found that has achieved this is llamalife.co. If you are on their home page and install the PWA, once you click on "Install" button, the page suddenly redirect to "/howToInstall" and then close to launch the PWA. Not sure how to implement this behavior. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Typically, you would want to use the useEffect(() ={
if (typeof window === 'undefined') return;
window.addEventListener('appinstalled', () => {
navigate('/')
})
return () => /* remove the event listener here */
}, []) Something like this should get the job done 👍. Lemme know if it worked for you or you found a better approach. Have a look at: https://developer.mozilla.org/en-US/docs/Web/API/Window/appinstalled_event whilst at it. |
Beta Was this translation helpful? Give feedback.
Typically, you would want to use the
appinstalled
event available on theWindow
interface. In your root, or layout route, you can do something like this:Something like this should get the job done 👍. Lemme know if it worked for you or you found a better approach. Have a look at: https://developer.mozilla.org/en-US/docs/Web/API/Window/appinstalled_event whilst at it.