- Make Supabase browser client a singleton to maintain WebSocket connection - Fix useEffect dependency array to prevent subscription re-creation - Add subscription status logging for debugging 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
18 lines
440 B
TypeScript
18 lines
440 B
TypeScript
import { createBrowserClient } from '@supabase/ssr'
|
|
import type { Database } from '@/types/database'
|
|
|
|
let browserClient: ReturnType<typeof createBrowserClient<Database>> | null = null
|
|
|
|
export function createClient() {
|
|
if (browserClient) {
|
|
return browserClient
|
|
}
|
|
|
|
browserClient = createBrowserClient<Database>(
|
|
process.env.NEXT_PUBLIC_SUPABASE_URL!,
|
|
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!
|
|
)
|
|
|
|
return browserClient
|
|
}
|