Google OAuth
Let users sign in with their Google account in one click.
How it works
When a user clicks "Continue with Google", they are redirected to Google's consent screen. After approval, Supabase exchanges the authorization code and creates a session. The callback at /api/auth/callbackupserts the user's profile row in your database and redirects them to the dashboard.
Step 1 — Create a Supabase project
- Go to supabase.com and create a new project.
- Under Settings → API, copy your Project URL and anon key.
- Add them to
.env.local:
NEXT_PUBLIC_SUPABASE_URL=https://xxxx.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJ...NoteBefore continuing, make sure you have set up the
profiles table. See the Database guide — it only takes a couple of SQL queries.Step 2 — Enable Google in Supabase
- In Supabase: Authentication → Providers → Google.
- Toggle it on and copy the Callback URL shown on that page.
Step 3 — Create a Google OAuth client
- Go to Google Cloud Console → APIs & Services → Credentials → Create OAuth 2.0 Client ID (Web application).
- Authorized JavaScript origins:
http://localhost:3000andhttps://yourdomain.com - Authorized redirect URIs: paste the Supabase callback URL from Step 2.
- Copy the Client ID and Client Secret.
Step 4 — Paste credentials into Supabase
Back in Supabase → Authentication → Providers → Google, paste the Client ID and Secret, then save.
Step 5 — Add the service role key
Webhooks and admin operations bypass Row Level Security using the service role key. Copy it from Supabase → Settings → API → service_role:
SUPABASE_SERVICE_ROLE_KEY=eyJ...WarningNever expose the service role key in client-side code or commit it to version control. It bypasses all Row Level Security policies.
Test it
Run npm run dev and go to /signin. Click "Continue with Google". You should land on /dashboard after authenticating.