import { createClient } from '@supabase/supabase-js'; const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL; const supabaseAnonKey = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY; if (!supabaseUrl) { console.error('Error: Missing Supabase URL. Please set NEXT_PUBLIC_SUPABASE_URL in .env.local'); } if (!supabaseAnonKey) { console.error('Error: Missing Supabase Anon Key. Please set NEXT_PUBLIC_SUPABASE_ANON_KEY in .env.local'); } // Ensure client is only created if keys are present, to avoid errors during build or in environments where keys might not be set. // The actual fetch operations in components should handle cases where supabase might not be initialized. let supabaseInstance = null; if (supabaseUrl && supabaseAnonKey) { supabaseInstance = createClient(supabaseUrl, supabaseAnonKey); } else { console.warn('Supabase client not initialized due to missing URL or Anon Key. App will run without Supabase functionality.'); } export const supabase = supabaseInstance;