Authentication
Shipfastai uses Supabase Auth for secure, scalable authentication.
Features
•Email/password authentication
•Magic link (passwordless) login
•Social providers (Google, GitHub, etc.)
•Row Level Security (RLS) integration
•Automatic session management
Basic Usage
Sign Up
import { supabase } from '@/lib/supabase';
const { data, error } = await supabase.auth.signUp({
email: 'user@example.com',
password: 'secure-password',
});
Sign In
const { data, error } = await supabase.auth.signInWithPassword({
email: 'user@example.com',
password: 'secure-password',
});
Sign Out
await supabase.auth.signOut();
Social Login
Enable Providers
1. Go to Supabase Dashboard > Authentication > Providers
2. Enable desired providers (Google, GitHub, etc.)
3. Add OAuth credentials
Implementation
const { data, error } = await supabase.auth.signInWithOAuth({
provider: 'google',
options: {
redirectTo: ${window.location.origin}/auth/callback,
},
});
Protected Routes
Use the auth context to protect routes:
import { useAuth } from '@/hooks/use-auth';
import { redirect } from 'next/navigation';
export default function DashboardPage() {
const { user, loading } = useAuth();
if (loading) return
if (!user) redirect('/login');
return
}
Session Management
Sessions are automatically refreshed. Access the current user:
const { data: { user } } = await supabase.auth.getUser();