Next.js Discord

Discord Forum

Trigger signIn('okta') programmatically (Next 14 & Next-auth 5 beta.13 )

Unanswered
Capelin posted this in #help-forum
Open in Discord
CapelinOP
Hello, in middleware.ts, I redirect calls if the user is not logged in to a page called login. On the login page, I have this simple signIn code. Clicking on the button takes users to the Okta login page, which is expected. Now I am wondering how I can skip this button click and directly take users to the provider's login page.
I appreciate your help and suggestions.


import { signIn } from '@/auth';
const SignIn = () => {
return (
<form
action={async () => {
'use server';

await signIn('okta' );
}}
>
<button type='submit'>Sign in with Okta</button>
</form>
)
}
export default SignIn;

1 Reply