Pages
NextAuth.js automatically creates simple, unbranded authentication pages for handling Sign in, Sign out, Email Verification and displaying error messages.
The options displayed on the sign up page are automatically generated based on the providers specified in the options passed to NextAuth.js.
Example
To add a custom login page, for example. You can use the pages
option:
Sign in
OAuth sign in page
In order to get the available authentication providers and the URLs to use for them, you can make a request to the API endpoint /api/auth/providers
:
tip
The signin() method automatically sets the callback URL to the current page. Using a link as a fallback means it sign in can work even without client side JavaScript.
Email sign in page
If you create a custom sign in form for email sign in, you will need to submit both fields for the email address and csrfToken from /api/auth/csrf in a POST request to /api/auth/signin/email.
This is easier if you use the build in signin()
function, as it sets the CSRF token automatically.
tip
To create a sign in page that works on clients with and without client side JavaScript, you can use both the signin() method and the csrfToken() method