router_shiny | R Documentation |
The router_server()
and router_ui()
functions are used to render page
modules served by a [router()]
into a Shiny application.
The content for the current page will be rendered in place of router_ui()
.
This can appear anywhere inside the UI definition, so that common UI elements
like head()
tags don't need to be repeated in each page module.
router_server()
can be called from anywhere inside the server()
function
of the Shiny application.
router_ui(id = "__router__") router_server(router, input, output, session, id = "__router__")
id |
Router id. |
router |
A shinypages |
input |
Shiny server |
output |
Shiny server |
session |
Shiny server |
router_server()
returns a Shiny observer reference class object.
See shiny::observe()
for details.
router_ui()
returns an HTML output element.
router()
if (interactive()) { ui_test <- function(id) { htmltools::div( htmltools::p("Test!"), htmltools::p(htmltools::a(href = router_link("/"), "Home")) ) } test_router <- router(router_page("home", ui_test)) ui <- shiny::fluidPage( router_ui() ) server <- function(input, output, session) { router_server(test_router, input, output, session) } shiny::shinyApp(ui, server) }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.