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),
},
});