-
I'm a bit confused on how to redicrect to a page after signin (how to set the callbackUrl). redirect: async (url, baseUrl) => {
return url.startsWith(baseUrl)
? Promise.resolve(url)
: Promise.resolve(baseUrl)
}, When I click the signin button (signin from next-auth/client), I get redirected to: How can I set the |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
You can pass a <div onClick={() => signIn('twitter', { callbackUrl: 'http://localhost:3000/path/to/callback' })}> You can also run custom checks on the login route and check for a session, then redirect if true. Example using export const getServerSideProps = async ({ req }) => {
const _providers = await providers()
const session = await getSession({ req })
if (session) {
return {
props: {},
redirect: {
destination: '/',
permanent: false
}
}
}
return {
props: {
providers: _providers // pass providers to component
}
}
} |
Beta Was this translation helpful? Give feedback.
-
I tried using the |
Beta Was this translation helpful? Give feedback.
You can pass a
callbackUrl
to thesignIn()
method, and use it like this:You can also run custom checks on the login route and check for a session, then redirect if true. Example using
getServerSideProps
and passing providers to the signin component for creation of sign in buttons.