signIn hook not redirecting directly to the good provider #2734
-
Question 💬`Hello, and thank you for this wonderful library. I have a simple issue, I'm trying to use the signIn hook, and it works well, but I would like to directly start the google workflow, and not having the sign in page. Here's my implementation. <a onClick={() => signIn("google", { callbackUrl: "/" })}>
<span className="sr-only">Sign in with Google</span>
</a> But at the moment, each time I'm clicking that span, it redirects me on the sign in page. I'm on version 3.27.3 of next-auth. Thanks! How to reproduce ☕️<a onClick={() => signIn("google", { callbackUrl: "/" })}>
<span className="sr-only">Sign in with Google</span>
</a> Contributing 🙌🏽Yes, I am willing to help answer this question in a PR |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Tell me if that works. |
Beta Was this translation helpful? Give feedback.
signIn
is usually associated with the action of signing in, and not a page navigation, so I think more often you want to use abutton
element. Especially in this case, where you have anonClick
event handler on ana
that has nohref
. If I had to guess, you have to do call.preventDefault()
beforesignIn
.Tell me if that works.