Authentication Methods
Email/Password Signup
Create a new user account with email and password. Endpoint:POST /auth/v1/signup
User’s email address (must be valid email format)
User’s password (minimum 6 characters)
User’s display name (stored in user metadata)
The signup method is implemented in
use-auth.tsx:155-168 as signUpWithPassword.Password Login
Sign in with existing credentials. Endpoint:POST /auth/v1/token?grant_type=password
Must be
password for password grant flowUser’s email address
User’s password
The password sign-in method is implemented in
use-auth.tsx:149-153 as signInWithPassword.Google OAuth
Sign in with Google OAuth provider. Endpoint:GET /auth/v1/authorize?provider=google
OAuth provider, must be
googleCallback URL after OAuth completes
The Google OAuth method is implemented in
use-auth.tsx:170-180 as signInWithGoogle.Auth Callback
After OAuth completes, Google redirects to the callback route. Endpoint:GET /auth/callback
Supabase auth code to exchange for session
Relative redirect path after successful exchange
next parameter (default /app)
The callback route exchanges the OAuth code for a session and sets cookies before redirecting the user.
Session Management
Get Current User
Retrieve the authenticated user’s information. Endpoint:GET /auth/v1/user
Headers:
Supabase anon/service key
Bearer token:
Bearer {access_token}Sign Out
Log out the current user session. Endpoint:POST /auth/v1/logout
Headers:
Supabase anon/service key
Bearer token:
Bearer {access_token}The sign-out method is implemented in
use-auth.tsx:182-189 with a fallback to local sign-out if the remote call fails.Auth Context
8Space provides a React context for managing authentication state throughout the app.AuthProvider
Wrap your app withAuthProvider to provide auth context:
useAuth Hook
Access authentication state and methods:Current Supabase session object
Current authenticated user
User profile with
id, displayName, and avatarUrlTrue during initial session bootstrap (max 15 seconds)
(email: string, password: string) => Promise<void>(email: string, password: string, name: string) => Promise<void>() => Promise<void>() => Promise<void>Session Bootstrap
TheAuthProvider automatically restores sessions on mount:
- Call
supabase.auth.getSession()to restore session from cookies/localStorage - If session exists, fetch user profile from
profilestable - Set
session,user, andprofilein context - Set
loadingtofalse - Subscribe to auth state changes
The bootstrap logic is implemented in
use-auth.tsx:74-113.Auth State Changes
TheAuthProvider listens for auth state changes and updates context:
Auth state change listener is implemented in
use-auth.tsx:115-132.Profile Fetching
User profiles are fetched from theprofiles table:
The
fetchProfile function is implemented in use-auth.tsx:21-41.Making Authenticated Requests
All Supabase Data and RPC endpoints require authentication: Required Headers:Supabase anon key from project settings
Bearer token with format:
Bearer {access_token}Error Handling
Common Error Codes:Invalid credentials or validation error
Missing or invalid authentication token
User lacks permission (RLS policy denied access)
Security Best Practices
- Use Row Level Security (RLS): Enable RLS policies on all tables to enforce access control
- Validate inputs: Always validate user inputs before sending to the API
- Handle token refresh: Supabase automatically refreshes tokens, but handle errors gracefully
- Secure redirects: Validate redirect URLs to prevent open redirect vulnerabilities
- Use HTTPS: Always use HTTPS in production to protect tokens in transit
Next Steps
API Overview
Explore all available API endpoints