replaceResponse: replaceResponse (loader/action helper)

View source: R/helpers.R

replaceResponseR Documentation

replaceResponse (loader/action helper)

Description

https://reactrouter.com/api/utils/replace

Usage

replaceResponse(to)

Arguments

to

Character. Destination path.

Details

Returns a JS loader function that performs a replace navigation to to – same as redirect, but the new entry replaces the current one in the history stack instead of pushing a new one. Use for "alias" routes where the original URL should not remain in the user's back-history.

Renamed from replace() to avoid masking base::replace. This mirrors the dataResponse() naming for the same reason.

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

Value

A JS expression suitable for the loader argument of Route.

Examples

## Not run: 
Route(path = "/legacy", loader = replaceResponse("/new"), element = NULL)

## End(Not run)


reactRouter documentation built on May 10, 2026, 5:07 p.m.