Call Two Shiny Apps from R Script

When someone lands on a page,, for example I need to extract values from the URL and send these values to a Shiny App.

What I have works in R Studio but fails when placed in /srv/shiny-server/update. The error is:

An error has occurred! Can't call runApp() from within runApp() . If your application code contains runApp() , please remove it.

I understand that you can't call a Shiny app from a Shiny app. But I thought when I do stopApp(tmp) the first Shiny app I call stops so that I can call the next one.

How can I get this to work when it's "live"?

R Script 1 - app.R that resides at /srv/shiny-server/update


email <- url_values[[1]]
wb_id <- url_values[[2]]

shiny_as_f(email, wb_id)

# Sample URL parameters
# ?

Shiny App 1 - shiny_get_from_url_f.R

# Get values from URL


url_values <- runApp(list(
  ui = fluidPage(
  server = function(input, output, session) {
      query <- parseQueryString(session$clientData$url_search)
      email <- query[['email']]
      email <- str_replace(email, " " , "+")
      wb_id <- query[['wb_id']]
      if (!is.null(email) & !is.null(wb_id)){
        tmp <- list(email, wb_id)

Shiny App 2 - call_shiny_as_f.R

# Shiny app as function that displays variables


shiny_as_f <- function(x, y){
    ui <- fluidPage(
    server <- function(input, output, session) {
      output$value_1 <- renderText({ x })
      output$value_2 <- renderText({ y })
  shinyApp(ui, server)

This topic was automatically closed 54 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.