Skip to contents

Register server code. This should be placed in your shiny server, and have a corresponding router_ui() element.

Usage

router_server(router, input, output, session, id = "__router__")

Arguments

router

A router object.

input

Shiny server input object.

output

Shiny server output object.

session

Shiny server session object.

id

Router id.

Value

A shiny observer reference class object. See shiny::observe() for details.

Examples

## Only run examples in interactive R sessions
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)
}

shinyApp(ui, server)
}