
Run a startup version check and return a banner UI element
Source:R/version_check.R
check_app_version.RdCall this outside server() – typically in
global.R or at the top of app.R – and embed the returned
value directly in your UI definition. Because the check runs at startup
the banner is present on first render with no loading delay, and no
uiOutput() / renderUI() wiring is needed.
Arguments
- github_user
GitHub username or organisation that owns the repository.
- github_repo
Repository name. Also used as the package name for
utils::packageVersion().- app_version
Optional fallback version string for environments where the package is not installed (e.g. shinyapps.io). Pass the result of your
app_version()function here. Ignored whenpackageVersion()succeeds.- verbose
Logical; if
TRUEa banner is always returned. Defaults toFALSE.
Value
A shinyWidgets::alert() UI element, or NULL when there
is nothing to show (up to date in non-verbose mode).
Details
Normal mode (verbose = FALSE): returns a banner only when
a newer version is available or when the check fails. Returns NULL
when the app is up to date (Shiny silently ignores NULL in the UI).
Verbose / debug mode (verbose = TRUE): always returns a
banner – including a success banner when up to date – so you can confirm
the check ran and inspect both version strings during development.
Examples
if (FALSE) { # \dontrun{
# global.R or top of app.R
source("version_check.R")
version_banner <- check_app_version(
github_user = "my-org",
github_repo = "my-shiny-app",
app_version = app_version() # fallback for shinyapps.io
)
# ui.R
fluidPage(
version_banner,
# ... rest of UI
)
# Verbose mode for development
version_banner <- check_app_version(
github_user = "my-org",
github_repo = "my-shiny-app",
app_version = app_version(),
verbose = TRUE
)
} # }