End-to-end auth flow: GitHub OAuth callback, session management, middleware protection, and logout handling in Next.js + Supabase.
Checklist
Auto-generated from the 10 rules this article references — each links to the enforceable rule.
References
Addresses
Rules
Call auth.getUser() immediately after creating the server client in middlewareKeep server actions in dedicated filesReturn the supabaseResponse object unchanged from middlewareUse requireAuth() as the first call in every authenticated server actionUse revalidatePath after server action mutationsValidate all server action inputs at the boundaryValidate and sanitize all user inputReturn structured results from server actionsRevalidate all affected paths after mutationsUse (select auth.uid()) instead of auth.uid() in policies
Tags
nextjssupabase
More from this skill
Explore more rules and knowledge
BeforeMerge offers hundreds of code review rules, guides, and detection patterns to help your team ship better code.