Skip to contents

Usage

redirectDocument(to)

Arguments

to

Character. Destination path or absolute URL.

Value

A JS expression suitable for the loader argument of Route.

Details

Returns a JS loader function that performs a document redirect to to – a full page reload, as opposed to the client-side navigation that redirect performs. Use when navigating to a URL outside the router's control (e.g. a server-rendered page) so the browser fully unloads the SPA.

For conditional document redirects inside a custom loader/action, call window.jsmodule['@/reactRouter'].helpers.redirectDocument(to) from your own JS() string.

Examples

if (FALSE) { # \dontrun{
Route(
  path = "/docs",
  loader = redirectDocument("/static/docs/index.html"),
  element = NULL
)
} # }