Improve auth performance: cache profile, remove double fetch, reduce timeout

- Seed currentUser from localStorage instantly on load (no loading flash)
- Remove getSession() duplicate — onAuthStateChange handles everything
- Fetch fresh profile in background while cached version shows immediately
- Reduce fallback timeout from 5s to 2s
- Explicit Supabase client auth options for reliability

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Krao Hasanee
2026-03-27 10:41:42 -04:00
parent 41e4d58ab9
commit 195c828f8b
2 changed files with 35 additions and 16 deletions
+7 -1
View File
@@ -5,4 +5,10 @@ const key = import.meta.env.VITE_SUPABASE_ANON_KEY;
if (!url || !key) throw new Error('Missing Supabase environment variables. Check VITE_SUPABASE_URL and VITE_SUPABASE_ANON_KEY.');
export const supabase = createClient(url, key);
export const supabase = createClient(url, key, {
auth: {
persistSession: true,
autoRefreshToken: true,
detectSessionInUrl: false,
},
});