Next.js Discord

Discord Forum

NextAuth redirect after login

Answered
SharpieMaster posted this in #help-forum
Open in Discord
Avatar
SharpieMasterOP
I want it to redirect the user to /account after login instead of /
Answered by Risky did start the fire πŸ™ƒ
like [signIn(undefined, { callbackUrl: '/account' })](https://next-auth.js.org/getting-started/client#specifying-a-callbackurl)?
View full answer

25 Replies

Avatar
SharpieMasterOP
I am using t3-stack
Image
Avatar
SharpieMasterOP
how would I do this?
Avatar
Risky did start the fire πŸ™ƒ
Avatar
SharpieMasterOP
how do I use it?
Avatar
Risky did start the fire πŸ™ƒ
do you ever call signIn function?
Avatar
SharpieMasterOP
yes
"use client";
import React from "react";
import { signIn } from "next-auth/react";

const SignInButton = () => {
    return (
        <button
            onClick={() => {
                signIn();
            }}
        >
            Sign In
        </button>
    );
};

export default SignInButton;
Avatar
Risky did start the fire πŸ™ƒ
now look at the docs that i linked, and you should see what you can pass into signIn...
Avatar
SharpieMasterOP
i see
ohhh
for the arguments of the function?
I think i need to edit the default login page
how tho
Avatar
Risky did start the fire πŸ™ƒ
you don't have any options for this signIn?
Avatar
Risky did start the fire πŸ™ƒ
like [signIn(undefined, { callbackUrl: '/account' })](https://next-auth.js.org/getting-started/client#specifying-a-callbackurl)?
Answer
Avatar
SharpieMasterOP
no
Avatar
Risky did start the fire πŸ™ƒ
because when i tried it, this redirects me after sucsessfull...
Avatar
SharpieMasterOP
thx
Avatar
Risky did start the fire πŸ™ƒ
uhh, so what fixed it? did adding the signin parms or something else?
Avatar
SharpieMasterOP
Image
Avatar
Risky did start the fire πŸ™ƒ
oh ok, so this did fix it πŸŽ‰
Avatar
joulev & fuma pray for Schneider
@SharpieMaster this is not the first time you do this. Please only use this for messages that answer your question (your message or other people’s), not β€œthanks” or irrelevant messages
Avatar
SharpieMasterOP
sorry, I will not be doing that again