It\'s possible to use anchor links in flat Shiny apps relatively easily - https://stackoverflow.com/a/28605517/1659890.
However, is it possible for an external link
I found the other answer a little difficult to follow so I created the example below. To navigate to the Data Availability tab, place "?a=b" to at the end of your url. For example if hosting the app on port 7436 the following link will take you directly to the Data Availability page. http://127.0.0.1:7436/?a=b
library(shinydashboard)
library(shiny)
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(
sidebarMenu(id = "container",
menuItem("Channels", tabName = "lt_channels"),
menuItem("Data Availability", tabName = "data_avail")
)),
dashboardBody(
tabItems(
tabItem(tabName = "lt_channels",
h1("Test Fail")),
tabItem(tabName = "data_avail",
h1("Test Pass"))
)
)
)
server <- function(session, input, output){
observe({
query <- parseQueryString(session$clientData$url_search)
query1 <- paste(names(query), query, sep = "=", collapse=", ")
print(query1)
if(query1 == "a=b"){
updateTabItems(session, inputId = "container", selected = "data_avail")
}
})
}
shinyApp(ui = ui, server = server)
You could add a search query parameter to the URL (eg. href='www.myapp.com?tab=tab2
), and in the app that is being linked you would have to add a bit of logic that changes to a specified tab on initialization if the search string is present (eg. look at session$clientData$url_search
and if it exists and there's a tab
variable, then use updateTabsetPanel()
to go to that tab)