Skip to main content
8Space uses Supabase Auth for user authentication, supporting email/password and OAuth (Google) sign-in.

Client Setup

The Supabase client is initialized with auto-refresh and session persistence:
packages/app/src/integrations/supabase/client.ts
import { createClient } from '@supabase/supabase-js';

const supabaseUrl = import.meta.env.VITE_SUPABASE_URL;
const supabaseAnonKey = import.meta.env.VITE_SUPABASE_ANON_KEY;

export const supabase = createClient(supabaseUrl, supabaseAnonKey, {
  auth: {
    autoRefreshToken: true,
    persistSession: true,
    detectSessionInUrl: true,
  },
});

Sign Up

Create a new user account with email and password.
const { data, error } = await supabase.auth.signUp({
  email: '[email protected]',
  password: 'securePassword123',
  options: {
    data: {
      name: 'John Doe'
    }
  }
});

Request Body

email
string
required
User email address
password
string
required
User password (minimum 6 characters)
options.data
object
User metadata

Response

access_token
string
JWT access token
refresh_token
string
Refresh token for obtaining new access tokens
expires_in
integer
Token expiration time in seconds
token_type
string
Token type (bearer)
user
object
User object

Sign In with Password

Authenticate with email and password.
const { data, error } = await supabase.auth.signInWithPassword({
  email: '[email protected]',
  password: 'securePassword123',
});

Request Body

email
string
required
User email address
password
string
required
User password

Response

access_token
string
JWT access token for API requests
refresh_token
string
Token for refreshing the session
expires_in
integer
Seconds until token expiration
user
object
Authenticated user object with id and email

Sign In with OAuth

Initiate Google OAuth sign-in flow.
TypeScript
const { data, error } = await supabase.auth.signInWithOAuth({
  provider: 'google',
  options: {
    redirectTo: 'https://8space.app/auth/callback'
  }
});

// Redirects to Google OAuth consent screen
// After approval, redirects to callback URL with auth code

Parameters

provider
string
required
OAuth provider (google)
redirect_to
string
URL to redirect after authentication

Get Current User

Retrieve the authenticated user’s information.
const { data: { user }, error } = await supabase.auth.getUser();

Response

id
string
User UUID
email
string
User email address
user_metadata
object
Custom metadata including display name
app_metadata
object
System metadata managed by Supabase

Sign Out

End the current user session.
const { error } = await supabase.auth.signOut();

Response

Returns empty response with status 200 on success.

Error Handling

All authentication endpoints return errors in this format:
message
string
Human-readable error message
code
string
Error code identifier
details
string | null
Additional error details
hint
string | null
Suggestion for resolving the error

Security

All authenticated endpoints require these headers:
  • apikey: Supabase anon/service key
  • Authorization: Bearer token with JWT access token
Example
const headers = {
  'apikey': import.meta.env.VITE_SUPABASE_ANON_KEY,
  'Authorization': `Bearer ${session.access_token}`
};

Build docs developers (and LLMs) love