๐Ÿ“ฆ leonardomso / tanstack-better-auth-session

๐Ÿ“„ index.tsx ยท 12 lines
1
2
3
4
5
6
7
8
9
10
11
12import { createFileRoute, redirect } from "@tanstack/react-router";

export const Route = createFileRoute("/")({
  beforeLoad: ({ context }) => {
    const session = context.session;
    if (session) {
      throw redirect({ to: "/app" });
    }
    throw redirect({ to: "/login" });
  },
});