Skip to contents

Create a router page

Usage

router_page(
  path,
  ui_module,
  server_module = NULL,
  title = "",
  authorised = NULL,
  metadata = list()
)

Arguments

path

Path for this page.

ui_module

Shiny UI module to render.

server_module

Shiny server module to render.

title

Page title.

authorised

A function that determines whether the current session is authorised to view this page. The function should take a session object as input, and return TRUE if the session is authorised to view this page and FALSE otherwise.

metadata

An arbitrary list of page metadata. This can be accessed as a reactive via get_router_page() or used in router callbacks.

Value

A router_page object.

Examples

if (interactive()) {

ui_test <- function(id) {
  htmltools::p("Test!")
}

server_test <- function(id) {
  moduleServer(id, function(input, output, session) { })
}

home_page <- router_page("home", ui_test)
server_page <- router_page("server", ui_test, server_test)

is_admin <- function(session) {
  "admin" %in% session$groups
}

admin_page <- router_page("admin", ui_test, authorised = is_admin)
}