DEV Community

Vansh Wadhwa
Vansh Wadhwa

Posted on

How to Redirect to an external website with Remix

Remix has a useful redirect helper function which helps to quickly create a new redirect Response. You can use this function to redirect from a loader or action to another app route and another website.

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

export const action = async () => redirect("https://vanxh.dev");
Enter fullscreen mode Exit fullscreen mode

Just return a redirect response with the URL you want to redirect. You can also pass a status code as a second argument, which defaults to 302.

You can do the same from a loader:

export const loader = async () => redirect("https://vanxh.dev");
Enter fullscreen mode Exit fullscreen mode

Top comments (0)