How to use NextAuth with Web3Auth | Web3Auth

Auth.js (formerly known as NextAuth) is a runtime-agnostic library based on standard Web APIs. It deeply integrates with multiple modern JavaScript frameworks to provide a simple, extendable, and always private and secure authentication experience!


This is a companion discussion topic for the original entry at https://web3auth.io/docs/guides/next-auth
1 Like

Hi, it works fine for the first time login.

But when i reload the page it throws an error of duplicated token.

Could you please confirm the following: is the verifier a Custom Provider or a Social Login Provider in this case?.

Hey @bejarano.frederick

For rehydration, you can either invalidate and regenerate the idToken or use session to persist the login state.

Does it work with other NextAuth providers such as Discord or X?

Yes, it works with all NextAuth providers.

Noob question, can you provide a sample using Web3Auth No Modal? And does this work with the non-beta version of NextAuth like v4?

Hey @joween.flores

We have one example with Single Factor Auth SDK[web3auth-core-kit-examples/single-factor-auth-web/sfa-web-nextauth-example at main · Web3Auth/web3auth-core-kit-examples · GitHub], feel free to use the same setup and replace the SDK with Web3Auth No Modal.

Haven’t tested, but it should work. Let me know if you face any issue setting this up.