next-auth v5 no longer works with multiple credentials providers
Environment
System: OS: macOS 14.2.1 CPU: (8) arm64 Apple M1 Memory: 829.22 MB / 16.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 18.19.0 - ~/Library/Caches/fnm_multishells/1647_1705584306483/bin/node Yarn: 1.22.21 - ~/Library/Caches/fnm_multishells/1647_1705584306483/bin/yarn npm: 10.2.3 - ~/Library/Caches/fnm_multishells/1647_1705584306483/bin/npm pnpm: 8.14.0 - ~/Library/Caches/fnm_multishells/1647_1705584306483/bin/pnpm bun: 1.0.22 - /opt/homebrew/bin/bun Browsers: Safari: 17.2.1 npmPackages: next: 14.0.4 => 14.0.4 next-auth: 5.0.0-beta.5 => 5.0.0-beta.5 react: ^18 => 18.2.0
Reproduction URL
https://github.com/chungweileong94/nextauth-multi-credential-bug
Describe the issue
According to the documentation, we should able to create multiple credentials providers in Next Auth v5.
However, as soon as we add a second credentials provider, the server signIn function from NextAuth(...) will stop working. Even if I just add a unique id to the credentials provider, it will result the same issue too.
Also note that this was working fine in NextAuth v4
How to reproduce
- Create at least two credentials providers with unique ID.
- Call the
signInfunction fromNextAuth(...), with the corresponding credential provider ID.
Expected behavior
It should sign-in properly.
@chungweileong94 What is the solution for this, can we use multiple credentials provider?
@pgupta1795 it was fixed in #9471. However, it has yet to be released.
For now, you can use patch-package to patch it, until the proper fix is released.