Skip to main content

replace

replace

Framework Data

Summary

Reference Documentation ↗

A redirect Response that will perform a history.replaceState instead of a history.pushState for client-side navigation redirects. Sets the status code and the Location header. Defaults to 302 Found.

import { replace } from "react-router";

export async function loader() {
  return replace("/new-location");
}

Params

url

The URL to redirect to.

init

The status code or a ResponseInit object to be included in the response.

Returns

A Response object with the redirect status and Location header.

Translation © 2026 fanyi.dev · Original © 2026 React Training LLC, Remix Software Inc., Shopify Inc. (MIT)