I would like to detect when users connect to my shiny app on shinyapps.io after doing a page reload / browser refresh.
I'm using this code in my shiny app to create a shiny reactive refreshed
to be used later in the server logic:
# Catch refreshed page
shinyjs::runjs("
const pageAccessedByReload = window.performance.getEntriesByType('navigation')[0].type.includes('reload');
Shiny.onInputChange('refreshed', pageAccessedByReload);
")
This works fine if the instance on the shinyapps server is already up and running.
However, when the user initiates the instance, a "Please Wait" message appears on screen and when the app is served, the navigation type is set to "reload" instead of "navigate".
This happens in two different browsers (Edge and Firefox), so it's probably not related to the browser, but to the way the instances are initiated when the first user connects to the shinyapps server.
Maybe someone here could suggest a workaround?