15 lines
541 B
TypeScript
15 lines
541 B
TypeScript
|
|
import { createClient, type SupabaseClient } from '@supabase/supabase-js'
|
||
|
|
|
||
|
|
const supabaseUrl = import.meta.env['VITE_SUPABASE_URL'] ?? ''
|
||
|
|
const supabaseAnonKey = import.meta.env['VITE_SUPABASE_ANON_KEY'] ?? ''
|
||
|
|
|
||
|
|
function createSupabaseClient(): SupabaseClient {
|
||
|
|
if (!supabaseUrl || !supabaseAnonKey) {
|
||
|
|
// Return a stub client for tests/dev without Supabase configured
|
||
|
|
return createClient('http://localhost:54321', 'stub-key')
|
||
|
|
}
|
||
|
|
return createClient(supabaseUrl, supabaseAnonKey)
|
||
|
|
}
|
||
|
|
|
||
|
|
export const supabase = createSupabaseClient()
|