* Supabase Client Singleton Ensures exactly one Supabase client instance per browser tab. Prevents Navigator LockManager errors from duplicate client creation. Uses lazy initialization to avoid creating the client until it's actually needed. /
// Source: https://github.com/ImMrLucky/spectyra | License: MIT | Copyright 2026 Kent Hamilton (Spectyra)
// Provided via justclaw.it.com; keep this notice with the code.
/**
* Supabase Client Singleton
*
* Ensures exactly one Supabase client instance per browser tab.
* Prevents Navigator LockManager errors from duplicate client creation.
*
* Uses lazy initialization to avoid creating the client until it's actually needed.
*/
import { createClient, SupabaseClient } from '@supabase/supabase-js';
import { environment } from '../../../environments/environment';
// Global singleton guard (prevents duplicate init in dev/HMR)
const g = globalThis as any;
const GLOBAL_KEY = '__spectyra_supabase_client__';
let _client: SupabaseClient | null = null;
let _initializing = false;
/**
* Ge
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key