SecureStartKit

Authentication

Email/password and Google OAuth with Supabase Auth.

Overview

Authentication is handled by Supabase Auth with email/password and Google OAuth pre-configured. All auth actions are Server Actions with Zod validation and rate limiting.

How It Works

  1. Users sign up via /signup (email/password or Google)
  2. A Supabase trigger automatically creates a profiles row
  3. Protected routes redirect unauthenticated users to /login
  4. The middleware handles route protection

Auth Pages

RouteDescription
/loginEmail/password + Google OAuth
/signupRegistration with full name
/reset-passwordPassword reset via email
/auth/callbackOAuth/email verification callback

Adding Auth Providers

  1. Enable the provider in your Supabase project settings
  2. Add it to config.ts:
auth: {
  providers: ['email', 'google', 'github'],
}
  1. Add the login button in components/forms/login-form.tsx

Server Actions

All auth mutations go through actions/auth.ts:

  • login(formData) - Email/password login
  • signup(formData) - New account registration
  • loginWithGoogle() - Google OAuth redirect
  • resetPassword(formData) - Send reset email
  • logout() - Sign out and redirect

Each action validates input with Zod and applies rate limiting.

Getting the Current User

import { getUser, getUserWithProfile } from '@/lib/supabase/server'

// In a Server Component or Server Action:
const user = await getUser()
const { user, profile } = await getUserWithProfile()