Remix v2
- Import
@remix-run/nodeor runtime package- Where the response belongs
- Route
loaderoraction
Return redirects from Remix or React Router loaders and actions, choose a permanent status for URL moves, and avoid unsafe destinations.
In Remix v2, return redirect(url, status) from a route loader or action; the helper defaults to 302. Use 301 only when a public URL has permanently moved. Current React Router Framework Mode uses redirect from react-router in route loaders and actions, also defaulting to 302. Keep temporary login and form-flow redirects temporary, validate user-provided destinations, and test the deployed HTTP response.
Four quick questions, then a straight answer.
From your answers, this is quietly costing you traffic and nobody has the hours to chase it. Scaplet finds every affected page, drafts the fixes and tracks how AI answers mention you.
A data platform shipped 46 fixes without a ticket.
This looks handled. Re-check after a redesign, a migration or a big content push; that is when it breaks.
Your site is small and you have the time. Work through the steps on this page, starting with the pages that get the most traffic.
@remix-run/node or the relevant runtime package such as @remix-run/cloudflare. In the current React Router Framework Mode, import redirect from react-router. Both APIs produce a redirect response from a server-side route loader or action; you can also throw it to stop the loader or action early, as in a login guard. The import and route conventions depend on your installed major version.@remix-run/node or runtime packageloader or actionreact-routerloader or actionreact-routerredirect is not available in Declarative mode. Use a server or hosting redirect for an HTTP URL migration.The current React Router docs are the forward path for Remix's routing and data conventions, while Remix v2 documentation remains relevant to deployed v2 apps. Check package.json and your route setup before copying an import from an example.
Set-Cookie; preserve session or cache headers when the request flow requires them.import { redirect } from "react-router"
export function loader() {
return redirect("/guides/new-url", 301)
}import { redirect } from "@remix-run/node"
export function loader() {
return redirect("/guides/new-url", 301)
}redirect accepts absolute URLs and that the app should validate user-supplied values; untrusted values can create an open redirect.For large migrations, put stable path mappings in the deployment platform when it supports them. Use route code for conditional decisions rather than loading a large redirect table on every request without measuring latency.
4 questions people ask next, answered from the sources on this page.
Remix v2 documents a default 302 status. Pass a status such as 301 explicitly for a permanent public URL move.
In Framework Mode, import redirect from react-router and return redirect('/new-path', 301) from the route loader.
No. A login redirect depends on a visitor's session and is temporary. Reserve 301 for a public URL that has permanently moved.
The helper accepts absolute URLs. Validate or allowlist any user-provided return URL before redirecting to prevent open redirects.
Run the free audit, then approve the fixes. Every change can be undone.