How do you pass parameters to a shiny app via URL

You’d have to update the input yourself when the app initializes based on the URL. You would use the session$clientData$url_search variable to get the query parameters. Here’s an example, you can easily expand this into your needs

library(shiny)

shinyApp(
  ui = fluidPage(
    textInput("text", "Text", "")
  ),
  server = function(input, output, session) {
    observe({
      query <- parseQueryString(session$clientData$url_search)
      if (!is.null(query[['text']])) {
        updateTextInput(session, "text", value = query[['text']])
      }
    })
  }
)

Leave a Comment