Next.js Discord

Discord Forum

how do i protect route handlers with nextauth as well as get session data in those routes

Unanswered
English Lop posted this in #help-forum
Open in Discord
Avatar
English LopOP
all in title, im very confused

2 Replies

  const session = await getServerSession(authOptions);
  const role = session?.user.role;
  const token = session?.user.token;

and

 const { data: session } = useSession();
  const role = session?.user.role;
  const token = session?.user.token;