Authentication Methods
Email/Password Signup
Create a new user account with email and password. Endpoint:POST /auth/v1/signup
string
required
User’s email address (must be valid email format)
string
required
User’s password (minimum 6 characters)
string
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
string
required
Must be
password for password grant flowstring
required
User’s email address
string
required
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
string
required
OAuth provider, must be
googlestring
Callback 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
string
Supabase auth code to exchange for session
string
default:"/app"
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:
string
required
Supabase anon/service key
string
required
Bearer token:
Bearer {access_token}Sign Out
Log out the current user session. Endpoint:POST /auth/v1/logout
Headers:
string
required
Supabase anon/service key
string
required
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:Session | null
Current Supabase session object
User | null
Current authenticated user
UserProfile | null
User profile with
id, displayName, and avatarUrlboolean
True during initial session bootstrap (max 15 seconds)
function
(email: string, password: string) => Promise<void>function
(email: string, password: string, name: string) => Promise<void>function
() => Promise<void>function
() => 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:string
required
Supabase anon key from project settings
string
required
Bearer token with format:
Bearer {access_token}Error Handling
Common Error Codes:Bad Request
Invalid credentials or validation error
Unauthorized
Missing or invalid authentication token
Forbidden
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