auth-ui: redirectTo does not work for sign in
Bug report
- I confirm this is a bug with Supabase, not with my own application.
- I confirm I have searched the Docs, GitHub Discussions, and Discord.
Describe the bug
redirectTo param on the Auth component is ignored in email sign in
To Reproduce
<Auth
supabaseClient={supabase}
redirectTo={"http://localhost:3000/dashboard"}
/>
See related code in https://github.com/supabase/auth-ui/blob/main/packages/svelte/src/lib/Auth/interfaces/EmailAuth.svelte#L41-L47 (where sign up is using redirectTo but not sign in)
Expected behavior
redirectTo prop value to be honoured
Screenshots
N/A
System information
N/A
Additional context
We should be able to provide a better ux for users if we’re able to redirect them to where they were before when they sign in, just like we do for sign up
About this issue
- Original URL
- State: open
- Created a year ago
- Reactions: 10
- Comments: 15 (1 by maintainers)
This is not an issue, these components aren’t smart components and
redirectTois only supported forviewsthat send emails likemagic_link,sign_upandforgotten_password. The issue with the megaAuthcomponent is it’s doing too much and there is no type narrowing to show which property is available for whichview. I have since pulled the views out into individual components to make it easier to see what properties are available. So you can use<SignIn />component instead and you will see there is noredirectToproperty as you should handle this using theonAuthStateChangemethod from. thesupabase-jslibrary instead. In the case of NextJS you can find an example here https://github.com/supabase-community/supabase-by-example/blob/main/reset-flow/auth-ui/nextjs/app/auth/signin/sign-in-form.tsx and in the case of just a normal React app you can find an example here https://github.com/supabase-community/supabase-by-example/blob/main/reset-flow/auth-ui/react/src/routes/auth/signin.tsx.Oh shoot, that’s why my redirects are not working…I spent two hours trying to figure this out haha!
I’m really confused by this - it’s in the official docs that this should work, no?
https://supabase.com/docs/guides/getting-started/tutorials/with-nextjs
Thanks for this awesome solution! After looking at the supabase/auth-ui repo, it seems that the
<SignIn />component is actually just the<Auth />component with aview="sign_in"prop: https://github.com/supabase/auth-ui/blob/026a3824a7dbff1512a9bacb242ded7ff6b6c2d1/packages/react/src/components/Auth/ui/index.tsx#L47C1-L58C2 So the main thing to remember for redirecting after login would be, as you mentioned, thesupabase.auth.onAuthStateChangelistener which is also working with the<Auth />component:This helped alot thank you mate i was looking into this way to long.
Hey, +1 here. I was going through supabase docs today for a new project and the AuthUI seemed like the suggested way to handle Auth. Found the same issue in code as OP found in the EmailView. RedirectTo isn’t used.
Fix should be just providing options hash to signup call