Each subfolder is a runnable example. Launch any of them with:
reactRouter::reactRouterExample("<name>")
# or
shiny::runApp(system.file("examples", "<name>", package = "reactRouter"))
The recommended entry point is RouterProvider() paired with one of the
create*Router() functions. See
vignette("routers", package = "reactRouter") for guidance on choosing a
router and vignette("introduction", package = "reactRouter") for a tour.
| Example | What it shows |
|---|---|
| basic | Layout route, nested routes, Outlet(), Link(), splat * route |
| bslib | reactRouter inside a bslib::page_navbar() |
| star-wars-explorer | Larger app: dynamic segments, loaders, errorElement, MUI Material/Charts/DataGrid integration |
| shiny.fluent | Multi-page rhino + shiny.fluent dashboard (see folder README) |
| Example | What it shows |
|---|---|
| RouterProvider | The recommended entry point |
| createHashRouter | Hash-based data router (default choice) |
| createMemoryRouter | In-memory data router (wizards, embedded widgets) |
| MemoryRouter | Legacy component-based memory router |
| Example | What it shows |
|---|---|
| dynamic-segment | Minimal Route(path = ":id") + useParams() |
| useNavigate | Programmatic navigation |
| useNavigation | Reading navigation state |
| useLocation | Reading the current location |
| useParams | Reading route parameters |
| useSearchParams / setSearchParams | Reading and updating search params |
| useOutlet / useOutletContext | Outlet inspection and parent → child context |
| useLinkClickHandler | Custom link components |
| useViewTransitionState | View transitions |
| useRoutes | Routes-as-data (legacy Routes() API) |
| useInRouterContext | Detect whether you are inside a router |
| ScrollRestoration | Restore scroll position on navigation |
| Example | What it shows |
|---|---|
| useLoaderData | The basic loader + useLoaderData() pattern |
| useLoaderData-api | Loader fetching from a remote API |
| Form | Form() GET + loader, POST + action with useActionData() |
| useFetcher / useFetchers | Background fetches without navigation |
| useSubmit | Programmatic form submission |
| useRevalidator | Re-run the current loader on demand |
| shouldRevalidate | Skip loader re-runs when data is unchanged |
| Await / useAsyncValue / useAsyncError | Deferred / streaming loader data |
| useBlocker | Intercept navigation (e.g. unsaved-changes prompt) |
| Example | What it shows |
|---|---|
| redirect | redirect() from a loader |
| redirectDocument | Full-document redirect |
| replaceResponse | Replace history entry from a loader |
| dataResponse | Loader returning a typed Response |
| useRouteError | Catching loader/action errors |
createHashRouter() +
RouterProvider()), which supports loader, action, useLoaderData(),
useFetcher(), etc. The MemoryRouter example uses the
older component-style API (MemoryRouter() + Routes() + Route()) —
still supported in React Router v7, but new code should prefer the data
router style.RouterProvider() examples render as static HTML and can also be embedded
in Quarto / R Markdown documents — many use htmltools::browsable()
rather than shinyApp().Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.