Community resources
The community around NextAuth has created a ton of tutorials on how to use it in different scenarios and using different configurations. Here is a list of some of them in case it's helpful.
info
If you did not find a guide or tutorial covering your use case, please open an issue and let us know so that we can make an official guide for it and spread the knowledge!
Basic of NextAuth
- Securing pages and API routes
- How to restrict access to pages and API routes.
- Usage with class components
- How to use
useSession()
hook with class components.
- How to use
- Next.js Authentication with Okta and NextAuth.js 4.0
- Learn how to perform authentication with an OIDC Application in Okta and NextAuth.js.
Advanced
- Refresh Token Rotation
- How to implement refresh token rotation.
- LDAP Authentication
- How to use the Credentials Provider to authenticate against an LDAP database. This approach can be used to authenticate existing user accounts against any backend.
- Adding HTTP(S) Proxy Support
- Add support for HTTP/HTTPS Proxy support to
openid-client
in order to use NextAuth.js behind a corporate proxy or other locked down network.
- Add support for HTTP/HTTPS Proxy support to
- Using the Email Provider behind Corporate Email Scanning Services
- An internal tutorial on modifying the catch-all API Route to gracefully handle
HEAD
requests.
- An internal tutorial on modifying the catch-all API Route to gracefully handle
Adapters
- Custom models with TypeORM
- How to use models with custom properties using the TypeORM adapter.
- Creating a database adapter
- How to create a custom adapter, to use any database to fetch and store user / account data.
- Adding role based login to database session strategy
- Implement a role based login system by adding a custom session callback.
Testing
- Testing with Cypress
- How to write tests using Cypress.