Spaces:
Running
Running
File size: 579 Bytes
dc1f75e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | import { createClient } from '@supabase/supabase-js';
let _client: ReturnType<typeof createClient> | null = null;
export function getSupabase() {
if (!_client) {
const url = process.env.NEXT_PUBLIC_SUPABASE_URL;
const key = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;
if (!url || !key) {
throw new Error('Missing NEXT_PUBLIC_SUPABASE_URL or NEXT_PUBLIC_SUPABASE_ANON_KEY');
}
_client = createClient(url, key, {
auth: { flowType: 'pkce', persistSession: true, autoRefreshToken: true, detectSessionInUrl: false },
});
}
return _client;
}
|