main
Branches
main (2.15.2)dev
Versions
2.15.21.19.3v0.21.0
React Router v7 has been released. View the docs
replace

replace

This is a small wrapper around redirect that will trigger a client-side redirect to the new location using history.replaceState instead of history.pushState.

If JavaScript has not loaded, this will behave as a standard document-level redirect and will add a new entry to the history stack.

Just like redirect, it accepts a status code or a ResponseInit as the second parameter:

replace(path, 301);
replace(path, 303);
replace(path, {
  headers: {
    "Set-Cookie": await commitSession(session),
  },
});
Docs and examples licensed under MIT