Auto-refresh persistently displayed Shiny app when new version is deployed to RStudioConnect

Aaaand... because I couldn't help myself. A simple little example using shinyjs that seems to work for my not-very-thorough testing :smile:

The two important bits:

  • In the UI:
    shinyjs::useShinyjs(),
  • In the Server (10 seconds for testing):
shinyjs::runjs(
"function reload_page() {
  window.location.reload();
  setTimeout(reload_page, 10000);
}
setTimeout(reload_page, 10000);
")

You definitely don't need the shinyjs package to make this work, but it does make things a little easier :smile: Throwing the JavaScript into your HTML as a script tag, etc. would work just as well.

1 Like