How to protect routes using @supabase/ssr? (NextJS) #21468
Unanswered
OrhanTozan
asked this question in
Questions
Replies: 1 comment 9 replies
-
Put this in the route I suppose const {
data: { user },
} = await supabase.auth.getUser();
if (!user) {
return redirect("/login");
} You can see the full example here: https://github.com/vercel/next.js/blob/canary/examples/with-supabase/app/protected/page.tsx#L11-L17 If you want to do it for certain routes from in the middleware you can put that after |
Beta Was this translation helpful? Give feedback.
9 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I think I need to put something into middleware.ts. But the starter template already has code in middleware.ts. Im afraid that my code will hurt the existing code.
Beta Was this translation helpful? Give feedback.
All reactions