Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
You can read the original post in its original format on Rtask website by ThinkR here: {brochure}: multipage {shiny} apps, now on CRAN
A {shiny} app is a single page: one url, one UI, one server function. That is comfortable while the app stays small. As soon as you want an actual site — a home page, a contact page, one page per user, urls people can bookmark or send by email — you end up faking pages with tabs and conditionalPanel().
{brochure} takes the problem the other way around: every page is a real page, with its own url, its own UI, its own server function and its own Shiny session.
install.packages("brochure")
library(shiny)
library(brochure)
brochureApp(
page(
href = "/",
ui = fluidPage(
h1("Home"),
tags$a(href = "/contact", "Contact us")
),
server = function(input, output, session) {
# ...
}
),
page(
href = "/contact",
ui = fluidPage(h1("Contact"))
)
)
You run it as you would any Shiny app, and moving from one page to another is a plain link. A url can also carry a parameter — /user/:id, which the page reads back with get_keys().
Around that, {brochure} gives you what you expect from a web server: request and response handlers to log, serve a healthcheck or answer before Shiny ever runs, helpers to set and read cookies (and so carry state from one page to the next), redirections, and what it takes to serve the app behind a reverse proxy or on Posit Connect.
The trade-off: you leave the single page paradigm behind, and nothing computed on one page survives a navigation to another. That is what vignette("design") is about — worth reading before you start.
The full post, with examples and what this release brings:
👉 {brochure} 1.0.0 is now on CRAN
Documentation: colinfay.me/brochure.
This post is better presented on its original ThinkR website here: {brochure}: multipage {shiny} apps, now on CRAN
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
