aethex.live/lib/supabase/client.ts

18 lines
646 B
TypeScript

import { createBrowserClient } from '@supabase/ssr'
export function createClient() {
const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL
const supabaseAnonKey = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY
// During build/prerendering, env vars may not be available
// Return a placeholder that will be replaced at runtime
if (!supabaseUrl || !supabaseAnonKey) {
if (typeof window === 'undefined') {
// Server-side during build - return a mock that won't be used
return null as any
}
throw new Error('Missing Supabase environment variables')
}
return createBrowserClient(supabaseUrl, supabaseAnonKey)
}