Remix Logo
main (2.0.1)dev


This is a small wrapper around redirect that will trigger a document-level redirect to the new location instead of a client-side navigation.

This is most useful when you have a Remix app living next to a non-Remix app on the same domain and need to redirect from the Remix app to the non-Remix app:

import { redirect } from "@remix-run/node"; // or cloudflare/deno

export const action = async () => {
  const userSession = await getUserSessionOrWhatever();

  if (!userSession) {
    return redirect("/login");

  return json({ ok: true });

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

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