Closed user72356 closed 1 year ago
Try listening to supabase.auth.onAuthStateChange()
and redirect based on events/session chnages there.
Try listening to
supabase.auth.onAuthStateChange()
and redirect based on events/session chnages there.
I ended up using Auth.useUser()
and if the user exists then I do a router.replace("/")
. Do you see anything wrong with this approach?
const { user } = Auth.useUser();
const router = useRouter();
useEffect(() =>
{
if (user)
{
void router.replace("/");
}
}, [user, router]);
return <Auth supabaseClient={ supabase } appearance={ { theme: ThemeSupa } } />;
I forgot auth-ui
actually uses supabase.auth.onAuthStateChange()
under the hood, so your approach should work fine.
Using the latest version of @supabase/auth-ui-react (0.2.2) and @supabase/supabase-js (2.0.0)
In a React app (NextJS), using e-mail/password authentication, the redirectTo prop doesn't appear to do anything. No redirection takes place after login, although the login is successful.
This is how I'm using the component within a page:
The Supabase console has http://localhost:3000/ in the list of redirects.
I've tried with and without the forward slash.