Can I pass parameters to a shiny app via URL?

I have a shiny app

that starts off with 2 default parameters and then below alows the user to change these parameters via a side panel. Ideally for this application I would like to link to this app from a map that would have an href and a link that would provide the app the input$z and input$y

is that possible?

output$lineplot <- renderPlot({
        subds <- subset(skdat, ID == input$z)
        subds$datetime <- as.POSIXct(subds$Date, format = "%Y-%m-%dT%H:%M:%OS")
        ggplot(subds, aes(x = datetime, y = !!$y))) +

My other motivation is to be able to get rid of that sidebar so the graph is bigger

You'd have to update the input inside the app when initializes. You would use the session$clientData$url_search variable to get the query parameters.

This is a simple reproducible example, that would work with this type of url


ui <- fluidPage(

    titlePanel("Old Faithful Geyser Data"),

                        "Number of bins:",
                        min = 1,
                        max = 50,
                        value = 30)


server <- function(input, output, session) {
    # Here you read the URL parameter from session$clientData$url_search
        query <- parseQueryString(session$clientData$url_search)
        if (!is.null(query[['bins']])) {
            updateSliderInput(session, "bins", value = query[['bins']])
    output$distPlot <- renderPlot({
        x    <- faithful[, 2]
        bins <- seq(min(x), max(x), length.out = input$bins + 1)

        hist(x, breaks = bins, col = 'darkgray', border = 'white')

# Run the application 
shinyApp(ui = ui, server = server)

You can modify this to make it work with a reactive value for example and get rid of the controls.


HA! that is great! thanks again Andres!

If your question's been answered (even by you!), would you mind choosing a solution? It helps other people see which questions still need help, or find solutions if they have similar problems. Here’s how to do it:

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