Since Supabase requires our user to be authenticated to fetch tweets, it doesn't make sense for an unauthenticated user to visit the landing page. In this lesson, we implement protected routes that are only accessible to authenticated users.
Additionally, we create a /login
route to redirect unauthenticated users, which allows them to sign in with GitHub.
Redirect unauthenticated users
const {
data: { session },
} = await supabase.auth.getSession();
if (!session) {
redirect("/login");
}