README.md

{shinydisconnect} - Show a nice message when a Shiny app disconnects or errors

CRAN
version Build Status

Demo ยท Created by Dean Attali

A shiny app can disconnect for a variety of reasons: an unrecoverable error occurred in the app, the server went down, the user lost internet connection, or any other reason that might cause the shiny app to lose connection to its server.

{shinydisconnect} allows you to add a nice message to the user when the app disconnects. The message works both locally (running Shiny apps within RStudio) and on Shiny servers (such as shinyapps.io, RStudio Connect, Shiny Server Open Source, Shiny Server Pro). See the demo Shiny app online for examples.

If you find {shinydisconnect} useful, please consider supporting my work!

Table of contents

Examples

For interactive examples and to see all the features, check out the demo app.

Example 1: basic usage (code)

basic screenshot

Example 2: using parameters (code)

advanced screenshot

Example 3: full-width and vertically centered (code)

You can also use disconnectMessage2() to get a similar message box to this one.

special screenshot

Installation

To install the stable CRAN version:

install.packages("shinydisconnect")

To install the latest development version from GitHub:

install.packages("remotes")
remotes::install_github("daattali/shinydisconnect")

How to use

Call disonnectMessage() anywhere in a Shiny app's UI to add a nice message when a shiny app disconnects. disonnectMessage() has parameters to modify the text, position, and colours of the disconnect message.

Note that it's not possible to distinguish between errors and timeouts - they will both show the same message.

Without using this package, a shiny app that disconnects will either just show a greyed out screen if running locally (with no message), or will show a small message in the bottom-left corner that you cannot modify when running in a server.

Basic usage:

ui <- fluidPage(
  disconnectMessage(),
  actionButton("disconnect", "Disconnect the app")
)
server <- function(input, output, session) {
  observeEvent(input$disconnect, {
    session$close()
  })
}
shinyApp(ui, server)


Try the shinydisconnect package in your browser

Any scripts or data that you put into this service are public.

shinydisconnect documentation built on July 23, 2020, 5:08 p.m.