Auth Setup — Supabase OAuth (Static Export)
Current auth architecture: client-side Supabase OAuth with Google provider. No server-side session, no Prisma, no NextAuth runtime.
Legacy note: The old setup used NextAuth v5 + Prisma +
DATABASE_URL/DIRECT_URL/AUTH_SECRET/GOOGLE_CLIENT_ID/GOOGLE_CLIENT_SECRET. All of those are no longer used and should be removed from.env.localand Netlify env vars.
How it works
- User clicks “Sign in” →
buildSupabaseOAuthUrl()constructs a Supabase authorize URL for the Google provider. - User completes Google consent → Supabase redirects to
/auth/callbackwith tokens in the URL hash. completeSupabaseOAuthFromUrl()extracts the access/refresh tokens, fetches the user profile, and stores the session inlocalStorage.AuthSessionProviderreads localStorage on mount and provides the session viauseAuth()context.
Google OAuth credentials are configured inside Supabase (Authentication → Providers → Google) — not directly in the app.
Required environment variables
# Supabase project URL — from Supabase dashboard → Settings → API
NEXT_PUBLIC_SUPABASE_URL=https://your-project-ref.supabase.co
# Supabase anon key — from Supabase dashboard → Settings → API
NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJhbGc...
Both are public (NEXT_PUBLIC_) — safe to expose in the browser.
Optional
# Set to "0" to disable login UI entirely (read-only mode). Default: enabled.
NEXT_PUBLIC_STATIC_LOGIN_MODE=
# Bookmark backend: "supabase" | "legacy-api" | unset (auto)
NEXT_PUBLIC_BOOKMARK_SYNC_BACKEND=
Supabase setup
1. Get the URL and anon key
- Open supabase.com/dashboard → your project
- Left sidebar → Settings → API
- Copy Project URL →
NEXT_PUBLIC_SUPABASE_URL - Copy anon / public key →
NEXT_PUBLIC_SUPABASE_ANON_KEY
2. Enable Google OAuth provider
- Left sidebar → Authentication → Providers → Google
- Toggle Enable
- Paste your Google Client ID and Google Client Secret
(create them in Google Cloud Console → APIs & Services → Credentials → OAuth 2.0 Client IDs) - Save
3. Add allowed redirect URLs
- Left sidebar → Authentication → URL Configuration
- Add to Redirect URLs:
http://localhost:3000/auth/callback https://patttterns.com/auth/callback
Google Cloud Console — OAuth credentials
You still need a Google OAuth client, but its credentials go into Supabase, not into .env.local.
- Go to console.cloud.google.com → your project
- APIs & Services → Credentials → + Create Credentials → OAuth client ID
- Application type: Web application
- Authorized JavaScript origins:
http://localhost:3000 https://patttterns.com - Authorized redirect URIs — use Supabase’s callback URL (shown in the Supabase Google provider settings):
https://your-project-ref.supabase.co/auth/v1/callback - Copy the Client ID and Client Secret → paste them into Supabase (step 2.3 above).
Netlify environment variables
Site → Site configuration → Environment variables → Add variable
| Variable | Value |
|---|---|
NEXT_PUBLIC_SUPABASE_URL | Supabase project URL |
NEXT_PUBLIC_SUPABASE_ANON_KEY | Supabase anon key |
No other auth variables are needed.
Test locally
npm run dev
# Open http://localhost:3000
# Click "Sign in" → redirects to Google → returns to /auth/callback → session stored