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 https://merrittr.shinyapps.io/example-app/?bins=1
library(shiny)
ui <- fluidPage(
titlePanel("Old Faithful Geyser Data"),
sidebarLayout(
sidebarPanel(
sliderInput("bins",
"Number of bins:",
min = 1,
max = 50,
value = 30)
),
mainPanel(
plotOutput("distPlot")
)
)
)
server <- function(input, output, session) {
# Here you read the URL parameter from session$clientData$url_search
observe({
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.