Free auditStart free
GuideReact Router · Remix

React Router (Remix) redirects

Return redirects from Remix or React Router loaders and actions, choose a permanent status for URL moves, and avoid unsafe destinations.

4 min
read
4
sources
Oct 24, 2026
updated
Scaplet Editorial Team
author
In one line

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.

30-second check

Where does your site stand?

Four quick questions, then a straight answer.

1/4Have you checked your own site for this?
Summarize this page withChatGPTClaudePerplexityGoogleAI Mode
01Choose the API for the app version

Know which API your application uses

Remix v2 applications import the helper from @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.
App setup

Remix v2

Import
@remix-run/node or runtime package
Where the response belongs
Route loader or action
App setup

React Router Framework Mode

Import
react-router
Where the response belongs
Route module loader or action
App setup

React Router Data Mode

Import
react-router
Where the response belongs
Route object loader or action
App setup

Declarative mode (client-only routing)

Import
Navigation APIs
Where the response belongs
redirect 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.

02Checklist

Use 301 for a permanent public URL change

The redirect helper defaults to HTTP 302. Pass 301 explicitly for a public URL that has permanently moved, such as a renamed documentation route or product slug. Google treats 301 as a permanent redirect signal; use a temporary status for a short-lived decision such as a user session or a form submission flow.
First2
Use a clear one-to-one replacement when possible. A close page helps visitors understand the move; a homepage is rarely a good destination for unrelated removed URLs.
Update internal links and canonical URLs to the destination so requests do not depend on the redirect after every click.
Next1
If a POST action succeeds and should prevent form resubmission, use the appropriate post/redirect/get status, commonly 303, instead of making the destination permanent.
Then1
A redirect can include response headers such as Set-Cookie; preserve session or cache headers when the request flow requires them.
React Router Framework Mode route module
import { redirect } from "react-router"

export function loader() {
  return redirect("/guides/new-url", 301)
}
Remix v2 route module
import { redirect } from "@remix-run/node"

export function loader() {
  return redirect("/guides/new-url", 301)
}
03A route redirect versus hosting configuration

Choose the layer based on what determines the destination

Need

A known old route always maps to a fixed replacement

Use
Route loader or hosting redirect rule
Reason
A static mapping is easier to inspect, and a host rule can answer before the app runs.
Need

Destination depends on session, record, or request data

Use
Server loader or action
Reason
The route can inspect the request and choose a response.
Need

Redirect after a successful form submission

Use
Action redirect with a post/redirect/get status
Reason
The browser reaches the result page without resubmitting the POST on refresh.
Need

Destination comes from a return-to parameter

Use
Validated allowlist before redirecting
Reason
React Router documents that 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.

04How it works

Test the response, not only in-app navigation

  1. 1

    Request the old URL directly

    Open the public route in a fresh browser session or inspect it over HTTP. Check the status code and Location header; a client-side navigation can look correct even when direct requests behave differently.

  2. 2

    Follow every hop

    Follow the response through to the final page. Remove chains by mapping the original source directly to the final destination, and check for loops.

  3. 3

    Test the real request variants

    Check trailing slashes, query parameters, locale prefixes, and authenticated versus logged-out requests when they can change the route result.

  4. 4

    Confirm the final URL is useful

    Verify the destination returns a successful page with the expected content and canonical URL. Use Search Console URL Inspection for important migrated pages after deployment.

See 301 redirects and Google Search for permanent-move signals and redirect chains for cleanup checks.

Sources · 4

Every fact, linked and dated.

Official docs first. The date is when we last opened each page.
  • remix.run
  • reactrouter.com
  • google.com
  1. 01redirect | Remix v2 Documentationv2.remix.run · checked 2026-10-24
  2. 02redirect | React Routerreactrouter.com · checked 2026-10-24
  3. 03Route Module | React Routerreactrouter.com · checked 2026-10-24
  4. 04Redirects and Google Search | Google Search Centraldevelopers.google.com · checked 2026-10-24
Questions

Asked a lot.

4 questions people ask next, answered from the sources on this page.

01What status does Remix `redirect()` return by default?

Remix v2 documents a default 302 status. Pass a status such as 301 explicitly for a permanent public URL move.

02How do I return a 301 from a React Router loader?

In Framework Mode, import redirect from react-router and return redirect('/new-path', 301) from the route loader.

03Should login redirects use 301?

No. A login redirect depends on a visitor's session and is temporary. Reserve 301 for a public URL that has permanently moved.

04Can React Router redirect to a URL from a query parameter?

The helper accepts absolute URLs. Validate or allowlist any user-provided return URL before redirecting to prevent open redirects.

Free · 2 minutes

Tools point. Agencies advise. This one ships.

Run the free audit, then approve the fixes. Every change can be undone.

Free, no card60 secondsNobody will call you
  • 46 fixes shipped without a ticket Brightpipe
  • 0→7 ChatGPT citations in six weeks Paylane