GuidesAuth
Google Auth
Add Google OAuth sign-in to your app.
Docs are in beta — content is improving rapidly. Found something missing? Open an issue on GitHub or reach out on Twitter.
1. Create Google OAuth Credentials
- Go to the Google Cloud Console
- Create or select a project
- Navigate to APIs & Services → OAuth consent screen → choose External → fill in app name and emails
- Go to APIs & Services → Credentials → + CREATE CREDENTIALS → OAuth client ID
- Choose Web application
- Add Authorized JavaScript origins:
http://localhost:3000(dev)https://yourdomain.com(production)
- Add Authorized redirect URIs:
http://localhost:3000/api/auth/callback/google(dev)https://yourdomain.com/api/auth/callback/google(production)
- Copy the Client ID and Client Secret
2. Set Environment Variables
# .env.local
VITE_GOOGLE_CLIENT_ID=your-client-id.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=your-client-secret3. Test
- Run
pnpm dev - Navigate to
/auth/sign-in - A Sign in with Google button will appear
- Complete the OAuth flow
Production Checklist
- Add production domain to authorized origins and redirect URIs in Google Cloud Console
- Publish your OAuth consent screen to remove the 100-user limit
Troubleshooting
- Redirect URI mismatch — the URI in Google Cloud must exactly match
/api/auth/callback/google(no trailing slash) - "This app isn't verified" — normal in dev. Click Advanced → Go to app to proceed, or publish consent screen for production
- No Google button — check that both
VITE_GOOGLE_CLIENT_IDandGOOGLE_CLIENT_SECRETare set