Arguments
- ...
Additional Route props (see Details).
- element
The element to render when the route matches. Wrapped on the JS side in a no-DOM
Keyedcomponent so React remounts the subtree on every route change – this is required for Shiny output bindings (e.g.textOutput()) to reinitialise correctly when two routes render the same component shape with different namespaces. Unlike the previous<div>wrapper,Keyedadds no DOM node, so layouts like MUIGridthat require typed direct children keep working.- loader
Optional. A
JSexpression evaluating to a loader function, e.g.JS("({ params }) => fetch(...)"). For a plain unconditional redirect, useredirect. To embed static R data, serialize it first withjsonlite::toJSON()and wrap the result inJS().- action
Optional. A
JSexpression evaluating to an action function called byFormsubmissions anduseSubmit/useFetchersubmits.- errorElement
Optional. Element rendered when the route's
loader,action, or rendering throws.- key
Stable React key for the route's
element. Defaults to a random alphanumeric string perRoute()call, so each route's element has a distinct identity from its siblings – this is what causes React to unmount the previous route's subtree (and reinitialise its Shiny output bindings) when navigating between routes that render the same component shape. You almost never need to pass this explicitly. Note: this key only affects identity of the route'selement; it does not rebuild theRouterProviderdata router. The route tree is created once on mount and subsequentRoute()edits are ignored; to apply a new route tree at runtime, giveRouterProvideritself a changingkey(e.g. viashiny::renderUI).
Details
Internally the `element` is wrapped in a `shiny::div()` with a UUID key so, in case R shiny is used, shiny can differentiate each element.
Additional React Router Route props can be passed through ...:
path(Character): path pattern, supports:param, optional:param?, and splat*.index(Boolean): mark this as the index route of its parent.caseSensitive(Boolean): match the path case-sensitively.id(Character): stable route id, required for use withuseRouteLoaderData.handle(Any): arbitrary value exposed viauseMatchesfor breadcrumbs and similar use cases.shouldRevalidate(JS): function controlling whether the loader re-runs on a given navigation.lazy(JS): code-splitting hook returning aPromiseresolving to a route module.hasErrorBoundary(Boolean): explicit error-boundary flag (rarely needed whenerrorElementis provided).
