© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•4mo ago•
6 replies
Dexter

Auth in Page VS Auth in Middleware

Hello, I am currently exploring Auth using supabase and NextJs and I cannot figure out the correct "pattern" to go about auth. I do know how the latest supabase-ssr works (cookies, auth flow etc.) however I do not know what the best practices are.

From what I have gotten so far middleware intercepts every request, forwards the request to the supabase middleware and that simply checks if the user is authenticated. There you can redirect to login if not.

However I am not sure If I also need to check for an active session (supabase.getUser()) and redirect in each page I want protected or do it once in the middleware.

Am i understanding something wrong ?
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Multiple middleware auth
SupabaseSSupabase / help-and-questions
4y ago
Supabase Auth without middleware
SupabaseSSupabase / help-and-questions
4mo ago
Supabase Auth vs Better Auth?
SupabaseSSupabase / help-and-questions
2mo ago
auth.updateUser vs auth.admin.updateUserById
SupabaseSSupabase / help-and-questions
4y ago