FrontendNext.js · SupabaseOpen source
Shop Auth Scaffold
Next.js + Supabase Google sign-in with role-aware JWT claims.
Role · Author.
- OAuth
- Auth
- JWT
- Roles
Overview
Authentication foundation for an e-commerce storefront: Google OAuth through Supabase SSR, middleware-protected routes and role-based access using custom JWT claims verified server-side.
Architecture
Next.js App Router
Server components read the session; middleware guards protected routes.
Supabase
Auth provider plus a users table carrying each account's role.
What it does
Auth
- Google sign-in with Supabase SSR helpers
- OAuth callback route and session middleware
Roles
- JWT custom claims verified with jose
- Supabase SQL functions for assigning roles
- Admin user list
Engineering decisions
Roles in the token
Custom claims put the role in the JWT so pages can authorise without an extra round trip.