Learn R Programming

⚠️There's a newer version (0.3.1) of this package.Take me there.

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:

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

Basic tutorial article is available on Appsilon Data Science blog.

Source code

This library source code can be found on Appsilon Data Science's Github: https://github.com/Appsilon/shiny.router

How to install?

Note! This library is still in its infancy. Api might change in the future.

At the moment it's possible to install this library through devtools.

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

To install previous version you can run:

devtools::install_github("Appsilon/shiny.router", ref = "0.1.0")

Example

Visit /examples directory for some complete samples. Here's the basic usage:

router <- make_router(
  route("/", root_page),
  route("/other", other_page)
)

ui <- shinyUI(semanticPage(
  title = "Router demo",
  router_ui()
))

server <- shinyServer(function(input, output) {
  router(input, output)
})

shinyApp(ui, server)

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.

Changes in documentation

Both repository README.md file and an official documentation page are generated with Rmarkdown, so if there is a need to update them, please modify accordingly a README.Rmd file and run a build_readme.R script to compile it.

Troubleshooting

We used the latest versions of dependencies for this library, so please update your R environment before installation.

However, if you encounter any problems, try the following:

  1. Up-to-date R language environment

  2. Installing specific dependent libraries versions

    • magrittr

      install.packages("magrittr", version='1.5') 
    • shiny

      install.packages("shiny", version='0.14.2.9001')
  3. Missing semanticui dependency - one of our examples uses one of our others libraries, so please install it as well, when running that example. Repository: semanticui

Future enhacements

Appsilon Data Science

We Provide End-to-End Data Science Solutions

Get in touch dev@appsilondatascience.com

Copy Link

Version

Install

install.packages('shiny.router')

Monthly Downloads

681

Version

0.1.1

License

MIT + file LICENSE

Maintainer

Dominik Krzemi<c5><84>ski

Last Published

September 18th, 2018

Functions in shiny.router (0.1.1)

is_page

Is page
make_router

Creates router. Returned callback needs to be called within Shiny server code.
create_router_callback

Internal function creating a router callback function. One need to call router callback with Shiny input and output in server code.
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
parse_url_path

Parse url and build GET parameters list
cleanup_hashpath

Formats a URL fragment into a hashpath starting with "#!/"
change_page

Change the currently displayed page.
router_ui

Creates an output for router. This configures client side. Call it in your UI Shiny code. In this output ui is going to be rendered according to current routing.
route

Create single route configuration.
route_link

Route link Adds /#!/ prefix to link.
valid_path

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

Extract link name
get_page

Convenience function to retrieve just the "page" part of the input. This corresponds to what might be called the "path" component of a URL, except that we're using URLs with hashes before the path & query (e.g.: http://www.example.com/#!/virtual/path?and=params)
get_query_param

Convenience function to retrieve any params that were part of the requested page. The param values returned come from "httr::parse_url()"
callback_mapping

Create a mapping bewtween a ui element and a server callack
disable_bootstrap_on_bookmark

Fix conflicts when some bookmark uses bootstrap
page404

404 page
PAGE_404_ROUTE

Default 404 page