View source: R/brochureAppRoutr.R
| brochureApp | R Documentation |
This function is to be used in place of shinyApp(). It takes a series of
page()s, each with its own url, UI and server function, and serves them
from a single Shiny application.
brochureApp(
...,
onStart = NULL,
options = list(),
enableBookmarking = NULL,
content_404 = "Not found",
basepath = "",
req_handlers = list(),
res_handlers = list(),
wrapped = shiny::tagList
)
... |
The |
onStart |
A function that will be called before the app is actually run.
This is only needed for |
options |
Named options that should be passed to the |
enableBookmarking |
Can be one of |
content_404 |
The content served when no |
basepath |
The path your app is served under by a reverse proxy. It is
removed from the incoming url, so that what is left matches the href of your
|
req_handlers |
a list of functions that can manipulate the |
res_handlers |
A list of functions that can manipulate the httpResponse
object before it is send to the browser. Each function must take a |
wrapped |
A function taking the UI of a page and returning the UI
actually served. This is how every page gets the same shell: |
Behind a reverse proxy, basepath tells the app where it is mounted: it is
removed from the incoming path, and prepended to the urls the app emits.
On Posit Connect the mount is picked up on its own, from the
RStudio-Connect-App-Base-URL header, and basepath is not needed. That
header is not part of any published contract, so set basepath if you want
the behaviour pinned. Brochure also injects a small script registering the
handler server_redirect() talks to, which prefixes internal targets with
the mount.
A shiny.appobj
page() to declare a page, redirect() to answer an url with a
redirection, and vignette("deployment") to serve the app under a prefix.
library(shiny)
app <- brochureApp(
page(
href = "/",
ui = tagList(h1("Home")),
server = function(input, output, session) {}
),
page(
href = "/contact",
ui = tagList(h1("Contact"))
),
redirect(from = "/index.html", to = "/")
)
# Then run it as you would any Shiny app:
if (interactive()) {
shiny::runApp(app)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.