Supabase Authentication Integration
Supabase Auth provides a complete authentication system with user management, powered by PostgreSQL and JWT tokens.
Environment Variables
Required Server Variables
SUPABASE_SERVICE_ROLE_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9... # Service role key for admin operations
Required Client Variables
NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co # Your Supabase project URL
NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9... # Anonymous/public key
Note:
- You can set
SUPABASE_URLandSUPABASE_ANON_KEYwithout theNEXT_PUBLIC_prefix and Shipkit will automatically generateNEXT_PUBLIC_SUPABASE_URLandNEXT_PUBLIC_SUPABASE_ANON_KEYat build time for use on the client. - The non-prefixed variables are not accessible on the client; only the generated
NEXT_PUBLIC_*values are exposed.
Setup Instructions
-
Create a Supabase Account: Sign up at supabase.com if you haven't already
-
Create a Supabase Project:
- Go to your Supabase Dashboard
- Create a new project
- Wait for the project to be fully provisioned
-
Get Your API Keys:
- In your project dashboard, go to "Settings" → "API"
- Copy your "Project URL" and "anon/public" key
- For server-side operations, copy the "service_role" key
-
Configure Authentication:
- In Supabase Dashboard, go to "Authentication" → "Settings"
- Configure your site URL and redirect URLs
- Set up email templates and SMTP settings
-
Add Environment Variables:
NEXT_PUBLIC_SUPABASE_URL=https://your-project-id.supabase.co NEXT_PUBLIC_SUPABASE_ANON_KEY=your_anon_key_here SUPABASE_SERVICE_ROLE_KEY=your_service_role_key_here
Features Enabled
When these environment variables are configured, the following features become available:
- ✅ Email and password authentication
- ✅ Social OAuth providers (Google, GitHub, Discord, etc.)
- ✅ Magic link authentication
- ✅ Phone authentication (SMS)
- ✅ User profile management
- ✅ Row Level Security (RLS) integration
- ✅ Real-time subscriptions
- ✅ Built-in user dashboard
- ✅ Password reset functionality
- ✅ Email verification
Configuration Options
Advanced Configuration
You can enhance Supabase Auth with additional settings:
# Custom JWT expiry
SUPABASE_JWT_EXPIRY=3600 # 1 hour in seconds
# Custom SMTP configuration
SUPABASE_SMTP_HOST=your_smtp_host
SUPABASE_SMTP_PORT=587
SUPABASE_SMTP_USER=your_smtp_user
SUPABASE_SMTP_PASS=your_smtp_password
# OAuth provider configuration
SUPABASE_GOOGLE_CLIENT_ID=your_google_client_id
SUPABASE_GOOGLE_SECRET=your_google_secret
Supported OAuth Providers
Supabase supports major OAuth providers:
- GitHub
- Discord
- Microsoft
- Apple
- And more...
Configure these in your Supabase dashboard under "Authentication" → "Providers".
Testing
Supabase provides excellent testing capabilities:
- Use Supabase's built-in authentication testing
- Test OAuth flows with test applications
- Verify email delivery
- Test real-time features
- Monitor authentication events in dashboard
Production Deployment
Before going live:
- Ensure proper API key security
- Configure production domains in Supabase
- Set up proper SMTP for email delivery
- Configure OAuth applications for production
- Set up proper database backups
- Review Row Level Security policies
- Configure proper monitoring and alerts