Learn R Programming

shiny.router

A minimalistic router for your Shiny apps.

Now it's possible to recreate a state of your app, by providing a specific URL, like:

router_ui(
  route("<your_app_url>/main",  mainPageShinyUI),
  route("<your_app_url>/other", otherPageShinyUI)
)

How to install?

It's possible to install this library through CRAN

install.packages("shiny.router")

The most recent version you can get from this repo using remotes.

remotes::install_github("Appsilon/shiny.router")

How to use it?

Basic usage:

library(shiny)
library(shiny.router)

root_page <- div(h2("Root page"))
other_page <- div(h3("Other page"))

ui <- fluidPage(
  title = "Router demo",
  router_ui(
    route("/", root_page),
    route("other", other_page)
  )
)

server <- function(input, output, session) {
  router_server()
}

shinyApp(ui, server)

Check the tutorial for more details on how to start using shiny.router.

Examples

An application that showcases the shiny.router features can be found here:

It was built using two other Appsilon Open Source packages:

  • rhino - an R package designed to help building high quality, enterprise-grade Shiny applications at speed.
  • shiny.fluent - Microsoft's Fluent UI for Shiny apps.

You can also visit examples directory for some complete samples.

How to contribute?

If you want to contribute to this project please submit a regular PR, once you're done with new feature or bug fix.

Reporting a bug is also helpful - please use GitHub issues and describe your problem as detailed as possible.

Appsilon

Appsilon is a Posit (formerly RStudio) Full Service Certified Partner. Learn more at appsilon.com.

Get in touch opensource@appsilon.com

Explore the Rhinoverse - a family of R packages built around Rhino!

Copy Link

Version

Install

install.packages('shiny.router')

Monthly Downloads

681

Version

0.3.1

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Ryszard Szymański

Last Published

April 18th, 2023

Functions in shiny.router (0.3.1)

make_router

[Deprecated] Creates router.
router_ui

Create router UI
%:::%

::: hack solution
is_page

Is page
parse_url_path

Parse url and build GET parameters list
valid_path

Internal function that validates that path is defined in routes.
router_ui_internal

Creates router UI
router_server_internal

Create router pages server callback
router_server

Create router pages server callback
route_link

Route link
extract_link_name

Extract link name
get_page

Convenience function to retrieve just the "page" part of the input.
cleanup_hashpath

Formats a URL fragment into a hash path starting with "#!/"
create_router_callback

Internal function creating a router callback function. One need to call router callback with Shiny input and output in server code.
change_page

Change the currently displayed page.
callback_mapping

Create a mapping between a UI element and a server callback.
.onAttach

On Load
disable_bootstrap_on_bookmark

Fix conflicts when some bookmark uses bootstrap
route

Create single route configuration.
get_query_param

Get Query Parameters
get_url_hash

Internal function to get url hash with #!.
page404

404 page
PAGE_404_ROUTE

Default 404 page
attach_attribs

Attach 'router-hidden' class to single page UI content
log_msg

Helper function to print out log messages into Shiny using cat() and stderr(), as described on https://shiny.rstudio.com/articles/debugging.html