diff --git a/app/src/pages/index.tsx b/app/src/pages/index.tsx
index d7df913..70b5bf7 100644
--- a/app/src/pages/index.tsx
+++ b/app/src/pages/index.tsx
@@ -3,7 +3,11 @@ import LoginForm from '@/components/LoginForm';
import { useSupabase } from '@/utils/useSupabaseConfig';
export default function Index() {
- const { user, supabaseClient } = useSupabase();
+ const { user, supabaseClient, loading } = useSupabase();
+
+ if (loading) {
+ return null;
+ }
if (!user || !supabaseClient) {
return ;
diff --git a/app/src/utils/useSupabaseConfig.tsx b/app/src/utils/useSupabaseConfig.tsx
index a3c3ef3..3e4d1b1 100644
--- a/app/src/utils/useSupabaseConfig.tsx
+++ b/app/src/utils/useSupabaseConfig.tsx
@@ -5,6 +5,7 @@ import { useEffect, useState } from 'react';
export function useSupabaseConfig() {
const [supabaseUrl, setSupabaseUrl] = useState('');
const [supabaseToken, setSupabaseToken] = useState('');
+ const [loading, setLoading] = useState(true);
useEffect(() => {
async function fetchConfig() {
@@ -23,6 +24,8 @@ export function useSupabaseConfig() {
} catch (error) {
// Handle any error that might occur during fetching
console.error(error);
+ } finally {
+ setLoading(false);
}
}
@@ -50,11 +53,11 @@ export function useSupabaseConfig() {
}
};
- return { supabaseUrl, supabaseToken, setSupabaseConfig };
+ return { supabaseUrl, supabaseToken, setSupabaseConfig, loading };
}
export function useSupabaseClient() {
- const { supabaseUrl, supabaseToken } = useSupabaseConfig();
+ const { supabaseUrl, supabaseToken, loading } = useSupabaseConfig();
const [supabaseClient, setSupabaseClient] = useState();
useEffect(() => {
@@ -64,11 +67,11 @@ export function useSupabaseClient() {
}
}, [supabaseUrl, supabaseToken]);
- return supabaseClient;
+ return { supabaseClient, loading };
}
export function useSupabase() {
- const supabaseClient = useSupabaseClient();
+ const { supabaseClient, loading } = useSupabaseClient();
const [user, setUser] = useState(null);
useEffect(() => {
@@ -85,5 +88,5 @@ export function useSupabase() {
};
}, [supabaseClient]);
- return { user, supabaseClient };
+ return { user, supabaseClient, loading };
}