Configure Supabase Authentication for Production
Configure Supabase authentication settings for production deployment. Covers URL configuration, SMTP setup, and third-party OAuth providers.
Configure Supabase authentication for production with proper redirect URLs, SMTP email delivery, and OAuth providers like Google. MakerKit automatically detects enabled providers and displays the appropriate login buttons.
Required for login to work
Skipping these steps will cause authentication failures. Users will not be able to sign up, log in, or reset passwords without proper configuration.
Overview
| Configuration | Purpose | Where |
|---|---|---|
| Site URL | Base URL for your application | Supabase Dashboard |
| Redirect URLs | Allowed callback URLs after auth | Supabase Dashboard |
| Custom SMTP | Reliable email delivery | Supabase Dashboard |
| OAuth Providers | Google, GitHub, etc. login | Provider + Supabase |
Authentication URLs
Configure redirect URLs so Supabase knows where to send users after authentication.
Navigate to Settings
- Open your Supabase Dashboard
- Select your project
- Go to Authentication > URL Configuration
Site URL
Set this to your production domain:
https://yourdomain.comThis is the base URL Supabase uses for all authentication-related redirects.
Redirect URLs
Add your callback URL with a wildcard pattern:
https://yourdomain.com/auth/callback**The ** wildcard allows MakerKit's various authentication flows to work:
/auth/callback- Standard OAuth callback/auth/callback/confirm- Email confirmation/auth/callback/password-reset- Password reset flow
Multiple environments
Add redirect URLs for each environment:
- Production:
https://yourdomain.com/auth/callback** - Staging:
https://staging.yourdomain.com/auth/callback** - Vercel previews:
https://*-yourproject.vercel.app/auth/callback**
Domain Matching
A common authentication issue occurs when domains don't match exactly.
The Rule
Your Site URL, Redirect URLs, and actual application URL must match exactly, including:
- Protocol (
https://) - Subdomain (
www.or nowww) - Domain name
- No trailing slash
Examples
| Site URL | Application URL | Result |
|---|---|---|
https://example.com | https://example.com | Works |
https://example.com | https://www.example.com | Fails |
https://www.example.com | https://www.example.com | Works |
https://example.com/ | https://example.com | May fail |
Fix Domain Mismatches
If users report login issues:
- Check what URL appears in the browser when users visit your app
- Ensure Site URL in Supabase matches exactly
- Update Redirect URLs to match
- Configure your hosting provider to redirect to a canonical URL
Custom SMTP
Supabase's default email service has severe limitations:
- Rate limit: 4 emails per hour
- Deliverability: Low (often lands in spam)
- Branding: Generic Supabase branding
Configure a real SMTP provider for production.
Navigate to SMTP Settings
- Go to Project Settings > Authentication
- Scroll to SMTP Settings
- Toggle Enable Custom SMTP
Configuration
| Field | Description |
|---|---|
| Host | Your SMTP server hostname |
| Port | Usually 465 (SSL) or 587 (TLS) |
| Username | SMTP authentication username |
| Password | SMTP authentication password or API key |
| Sender email | The "from" address for emails |
| Sender name | Display name for the sender |
Provider Examples
Resend
Host: smtp.resend.comPort: 465Username: resendPassword: re_your_api_keySendGrid
Host: smtp.sendgrid.netPort: 587Username: apikeyPassword: SG.your_api_keyMailgun
Host: smtp.mailgun.orgPort: 587Username: postmaster@your-domain.mailgun.orgPassword: your_api_keyVerify Configuration
After saving SMTP settings:
- Create a test user with a real email address
- Check that the confirmation email arrives
- Verify the email doesn't land in spam
- Confirm links in the email work correctly
Third-Party Providers
MakerKit supports OAuth login through Supabase. Configure providers in both the provider's developer console and Supabase.
How It Works
- You enable a provider in Supabase Dashboard
- MakerKit automatically shows the login button in the UI
- No code changes required
Supported Providers
MakerKit displays login buttons for any provider you enable in Supabase:
- GitHub
- Apple
- Microsoft
- Discord
- Twitter/X
- And others supported by Supabase
General Setup Process
For each provider:
- Create OAuth App: Register an application in the provider's developer console
- Get Credentials: Copy the Client ID and Client Secret
- Set Callback URL: Add the Supabase callback URL to your OAuth app
- Configure Supabase: Enter credentials in Authentication > Providers
Google Setup
Google is the most common OAuth provider. Here's the setup:
In Google Cloud Console
- Go to console.cloud.google.com
- Create a new project or select existing
- Navigate to APIs & Services > Credentials
- Click Create Credentials > OAuth client ID
- Select Web application
- Add authorized redirect URI (from Supabase)
In Supabase Dashboard
- Go to Authentication > Providers
- Click Google
- Toggle Enable Sign in with Google
- Enter your Client ID and Client Secret
- Copy the Callback URL to Google Cloud
For detailed instructions, see Supabase Google Auth documentation.
Email Templates
MakerKit provides custom email templates that fix a common authentication issue with Supabase.
The PKCE Problem
Supabase uses PKCE (Proof Key for Code Exchange) for secure authentication. The PKCE verifier is stored in the browser that initiated the authentication.
When a user:
- Signs up on their laptop
- Receives confirmation email on their phone
- Clicks the link on their phone
Authentication fails because the phone doesn't have the PKCE verifier.
The Solution
MakerKit's email templates use token hash URLs instead of PKCE, which work regardless of which device opens the link.
See the Authentication Emails guide for setup instructions.
Troubleshooting
"Redirect URL not allowed" error
The callback URL doesn't match any configured Redirect URLs in Supabase.
- Check the exact URL in the error message
- Add it to Redirect URLs in Supabase
- Include the
**wildcard for flexibility
Users can't log in after email confirmation
Usually a domain mismatch issue. Verify:
- Site URL matches your application URL exactly
- Redirect URLs match your domain
- No trailing slashes causing mismatches
OAuth login fails silently
Check browser console for errors. Common issues:
- Callback URL in provider doesn't match Supabase
- OAuth credentials incorrect
- Provider not properly enabled in Supabase
Emails not received
- Check spam/junk folders
- Verify SMTP settings in Supabase
- Check your email provider's dashboard for delivery logs
- Ensure sender domain has proper DNS records (SPF, DKIM)
"Invalid PKCE verifier" error
Users clicking email links from different browsers/devices. Update to MakerKit's email templates. See Authentication Emails.
Security Considerations
Protect Your Credentials
- Never expose the Supabase Service Role Key in client code
- Store OAuth credentials securely (use environment variables)
- Rotate credentials if they're ever exposed
Configure Rate Limiting
Supabase has built-in rate limiting for authentication. Review settings in Project Settings > Auth to prevent abuse.
Monitor Authentication Events
Enable audit logging in Supabase to track:
- Failed login attempts
- Unusual activity patterns
- Password reset requests
Frequently Asked Questions
Why does authentication fail when users click email links?
How do I add Google login?
Can I use multiple OAuth providers?
Why are my authentication emails going to spam?
What's the redirect URL wildcard for?
How do I test authentication locally?
Next Steps
- Authentication Emails: Configure email templates with token_hash URLs
- Environment Variables: Complete variable reference
- Supabase Configuration: Full Supabase setup guide