How to detect the condition in which a Shiny app is served


I would like my Shiny app to know whether it is served by:

  1. Rstudio in a RStudio panel
  2. Rstudio in a web browser tab
  3. Any remote server

Using an interactive() call returns TRUE for options 1 and 2, and FALSE for 3... how can I distinguish between 1 and 2?



ui <- bootstrapPage(  
server <- function(input, output) {  
  output$condition <- renderPrint({ interactive() }) 

shinyApp(ui = ui, server = server)

Give the code below a try:

rstudioMode <- tryCatch({
  error = function(e) {

The code is wrapped in a tryCatch as versionInfo likes to throw if it is not in RStudio.


I will give this a try.

Hi @barret

rstudioMode has the same value (that is 'server') in cases 1 and 2 described in my original post. So, this has the same problem as interactive().

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.