Next.js Discord

Discord Forum

NextJS NextAuth Supabase Session Time

Unanswered
Madeiran sardinella posted this in #help-forum
Open in Discord
Avatar
Madeiran sardinellaOP
How do I set the session time for my cookie auth? I followed this implementation guide (https://supabase.com/docs/guides/auth/auth-helpers/nextjs)

I am signing users in as follows in my login component:
  const handleSignIn = async () => {
    setIsLoading(true);
    const data = await supabase.auth.signInWithPassword({
      email,
      password,
    });
    if (data?.data.user) {
      router.push("/dashboard");
    }
    setIsLoading(false);
    router.refresh();
  };


I also have this middleware:
export async function middleware(req: NextRequest) {
  const res = NextResponse.next();
  const supabase = createMiddlewareClient({ req, res });
  await supabase.auth.getSession();
  return res;
}


I am confused at how I can increase the session length, so that users don't need to reauth everyday

0 Replies