Next.js Discord

Discord Forum

how to create NextAuth signIn request?

Unanswered
Birman posted this in #help-forum
Open in Discord
BirmanOP
NextAuth documentation says:
All requests to /api/auth/* (signIn, callback, signOut, etc.) will automatically be handled by NextAuth.js.

How should such request be made in a button?
Which route I should call to?
Which function to use?
<Link href="???" passHref>
  <button onClick=(???) style={{ cursor: 'pointer' }}>Sign In</button>
</Link>

1 Reply

BirmanOP
Like this:
'use client'
import { signIn } from "next-auth/react";

const Header = () => {
    return (
        <header>
            <nav>
                <button onClick={() => signIn()} style={{ cursor: 'pointer' }}>Sign In</button>
            </nav>
        </header>
    );
};

export default Header;