8 lines · 362 B
import { redirect } from "@tanstack/react-router";
import type { Viewer } from "~/lib/types";

/** For sign-in, sign-up and recovery pages: someone already signed in goes to the dashboard instead. */
export function redirectSignedIn({ context }: { context: { viewer: Viewer | null } }): void {
  if (context.viewer) throw redirect({ to: "/", replace: true });
}