Redirect to an external website with Remix
Remix gives us a useful redirect
helper function which lets us quickly create a new redirect Response object. You can use this function to redirect from a loader or action to another app route and another website. Let's see how.
export async function action() {
return redirect("https://google.com");
}
That's it. 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 async function loader() {
return redirect("https://google.com");
}