Supabase Authentication provides a complete user management system that handles authentication, authorization, and user data. Built on top of PostgreSQL Row Level Security (RLS), it gives you fine-grained control over data access.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/supabase/supabase/llms.txt
Use this file to discover all available pages before exploring further.
Features
Supabase Auth offers multiple authentication methods:- Email & Password: Traditional authentication with optional email confirmation
- Magic Links: Passwordless authentication via email
- OAuth Providers: Social login with Google, GitHub, Apple, and more
- Phone Authentication: SMS-based login
- Multi-Factor Authentication (MFA): Add an extra layer of security with TOTP
- Anonymous Sign-ins: Allow users to explore your app before registering
How It Works
Authentication in Supabase follows these core principles:- User Identity: Users are stored in the
auth.userstable - Sessions: JWT tokens are issued and automatically refreshed
- Row Level Security: Database policies control data access based on user identity
- Secure by Default: All auth endpoints use secure cookies and HTTPS
Authentication Flow
Client Setup
Server-Side (Next.js)
app/lib/supabase/server.ts
Client-Side (Browser)
app/lib/supabase/client.ts
User Metadata
Store additional user information in two places:- User Metadata: Public data accessible in JWT tokens
- App Metadata: Private data only accessible server-side
Security Best Practices
Enable Email Confirmation
Verify user email addresses before granting access to sensitive features
Implement RLS Policies
Always enable Row Level Security on tables containing user data
Use Secure Passwords
Enforce strong password requirements in your application
Enable MFA
Offer multi-factor authentication for enhanced security
Next Steps
Sign Up Users
Learn how to register new users
Sign In Methods
Implement various sign-in methods
OAuth Integration
Add social login providers
Multi-Factor Auth
Secure accounts with MFA
