MyNixOS website logo
Description

Show a Nice Message When a 'Shiny' App Disconnects or Errors.

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. With 'shinydisconnect', you can call disonnectMessage() anywhere in a Shiny app's UI to add a nice message when this happens. Works locally (running Shiny apps within 'RStudio') and on Shiny servers (such as shinyapps.io, 'RStudio Connect', 'Shiny Server Open Source', 'Shiny Server Pro'). See demo online at <https://daattali.com/shiny/shinydisconnect-demo/>.

shinydisconnect

๐Ÿ”Œ Show a nice message when a Shiny app disconnects or errors

Demo ยท by Dean Attali

R build status CRAN version


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.

Need Shiny help? I'm available for consulting.
If you find {shinydisconnect} useful, please consider supporting my work! โค

This package is part of a larger ecosystem of packages with a shared vision: solving common Shiny issues and improving Shiny apps with minimal effort, minimal code changes, and clear documentation. Other packages for your Shiny apps:

PackageDescriptionDemo
shinyjs๐Ÿ’ก Easily improve the user experience of your Shiny apps in seconds๐Ÿ”—
shinyalert๐Ÿ—ฏ๏ธ Easily create pretty popup messages (modals) in Shiny๐Ÿ”—
shinyscreenshot๐Ÿ“ท Capture screenshots of entire pages or parts of pages in Shiny apps๐Ÿ”—
timevis๐Ÿ“… Create interactive timeline visualizations in R๐Ÿ”—
shinycssloadersโŒ› Add loading animations to a Shiny output while it's recalculating๐Ÿ”—
colourpicker๐ŸŽจ A colour picker tool for Shiny and for selecting colours in plots๐Ÿ”—
shinybrowser๐ŸŒ Find out information about a user's web browser in Shiny apps๐Ÿ”—
shinytip๐Ÿ’ฌ Simple flexible tooltips for Shiny appsWIP
shinymixpanel๐Ÿ” Track user interactions with Mixpanel in Shiny apps or R scriptsWIP
shinyforms๐Ÿ“ Easily create questionnaire-type forms with ShinyWIP

Table of contents

The problem

Have you ever noticed how an error in your Shiny app looks very different when it happens locally (in RStudio on your laptop) compared to when it happens in production (in shinyapps.io or Shiny Server or Connect)? Locally, when a Shiny app breaks, you just get a grey screen. But when a deployed app breaks, you also get a little strip that says "Disconnected from server. Reload."

shiny default message

You don't have any control over that message's text or position, and you don't have a way to get that message to appear both locally and in deployed apps.

Well, at least you didn't until now. {shinydisconnect} solves exactly these two issues, by allowing you to show a customized (and pretty!) message when a Shiny app disconnects or errors, regardless of where the app is running.

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

Example 4: hide the app

This can be achieved by setting the opacity to 1 (fully opaque).

special2 screenshot

Installation

For most users: To install the stable CRAN version:

install.packages("shinydisconnect")

For advanced users: To install the latest development version from GitHub:

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

How to use

The package only has two functions: disconnectMessage() and disconnectMessage2().

Call disconnectMessage() anywhere in a Shiny app's UI to add a nice message when a shiny app disconnects. disconnectMessage() has many 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)

You can use disconnectMessage2() as a pre-configured version of disconnectMessage() with a specific set of parameters.

Sponsors ๐Ÿ†

There are no sponsors yet

Become the first sponsor for {shinydisconnect}!

Metadata

Version

0.1.1

License

Unknown

Platformsย (77)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows