Auth.js v5 returns error Configuration instead of CredentialsSignin
Your error
signIn returned { error: 'Configuration' } for invalid credentials3 more lines it can showFix it fast
Most common cause, 1 of 3authorize throws a plain Error for a bad login
Return null for a normal wrong password, which Auth.js turns into CredentialsSignin.
// auth.ts
import NextAuth, { CredentialsSignin } from "next-auth"
import Credentials from "next-auth/providers/credentials"
class InvalidLogin extends CredentialsSignin {
code = "invalid_login"
}
export const { handlers, auth, signIn, signOut } = NextAuth({
providers: [
Credentials({
credentials: { email: {}, password: {} },
async authorize(credentials) {
const user = await getUserFromDb(credentials)
if (!user) throw new InvalidLogin()
return user
},
}),
],
})Short answer
next-auth 5 beta only passes a short list of error types to the browser. When authorize throws a plain Error, as the docs example does, Auth.js wraps it in CallbackRouteError and signIn returns error: 'Configuration'. Return null, or throw a class that extends CredentialsSignin, to get CredentialsSignin and a code. Applies to next-auth 5.0.0-beta.32.
Which cause do you have?
Try one wrong password and read the server terminal, not the browser. Auth.js logs the real error there with an [auth][cause] line. A message you wrote yourself points to cause 1, a library or database error to cause 2, and a failure after a correct password to cause 3.
npm run dev 2>&1 | grep -A3 '\[auth\]\[error\]'Then find the line you see in this list and open its fix:
- 1authorize throws a plain Error for a bad login
[auth][cause] shows your own text, such as Error: Invalid credentials., thrown from authorize - 2Something inside authorize fails before the password is checked
[auth][cause] names ZodError, a Prisma or database error, or a TypeError, not a message you wrote - 3The signIn or jwt callback throws after authorize succeeds
A correct password also returns Configuration, and the stack in [auth][cause] points into callbacks.jwt or callbacks.signIn
What does the error look like?
signIn returned { error: 'Configuration' } for invalid credentials[auth][error] CallbackRouteError: Read more at https://errors.authjs.dev#callbackrouteerror[auth][cause]: Error: Invalid credentials./api/auth/error?error=Configuration
Cause 1 of 3
authorize throws a plain Error for a bad login
You see[auth][cause] shows your own text, such as Error: Invalid credentials., thrown from authorize
Check
The Configuration result here comes from your own throw. Auth.js sends only client-safe types (CredentialsSignin, AccessDenied and a few others) to the browser; every other error becomes Configuration. Code that copies the credentials guide and runs throw new Error("Invalid credentials.") hits exactly that path.
grep -n "throw new Error" auth.tsFix
Return null for a normal wrong password, which Auth.js turns into CredentialsSignin. To show your own reason, throw a subclass of CredentialsSignin and set code; the code reaches the client next to the error. Keep the text vague so it does not reveal whether the email exists.
// auth.ts
import NextAuth, { CredentialsSignin } from "next-auth"
import Credentials from "next-auth/providers/credentials"
class InvalidLogin extends CredentialsSignin {
code = "invalid_login"
}
export const { handlers, auth, signIn, signOut } = NextAuth({
providers: [
Credentials({
credentials: { email: {}, password: {} },
async authorize(credentials) {
const user = await getUserFromDb(credentials)
if (!user) throw new InvalidLogin()
return user
},
}),
],
})Verify
A wrong password now gives error: 'CredentialsSignin' with code: 'invalid_login', and no CallbackRouteError line appears on the server.
// client form handler (next-auth/react)
const res = await signIn("credentials", { email, password, redirect: false })
console.log(res?.error, res?.code)Confirmed by raw.githubusercontent.com
Cause 2 of 3
Something inside authorize fails before the password is checked
You see[auth][cause] names ZodError, a Prisma or database error, or a TypeError, not a message you wrote
Check
An uncaught exception from a schema parse, a database call or a hash comparison also becomes CallbackRouteError, so the browser again sees Configuration. Blank or malformed form fields can trigger it, because parseAsync throws a ZodError instead of returning.
grep -n "parseAsync\|parse(" auth.ts lib/*.tsFix
Catch validation errors and return null, as the Auth.js credentials guide does with ZodError. Fix real database or runtime errors at their source instead of hiding them, since they will fail valid logins too.
import { ZodError } from "zod"
async authorize(credentials) {
try {
const { email, password } = await signInSchema.parseAsync(credentials)
return await findUser(email, password)
} catch (error) {
if (error instanceof ZodError) return null
throw error
}
}Verify
Submitting an empty form returns CredentialsSignin, and the server log no longer shows ZodError under [auth][cause].
npm run dev 2>&1 | grep -A2 '\[auth\]\[cause\]'Confirmed by authjs.dev
Cause 3 of 3
The signIn or jwt callback throws after authorize succeeds
You seeA correct password also returns Configuration, and the stack in [auth][cause] points into callbacks.jwt or callbacks.signIn
Check
For the Credentials provider, the CallbackRouteError notes in the Auth.js source list an uncaught error in the signIn or jwt callback as the other cause. A callback that reads a field your authorize result does not contain is a common trigger.
grep -n -A8 "callbacks" auth.tsFix
Guard every field the callbacks read, and return the token or true on the normal path. Only throw where you really want the sign-in to stop.
callbacks: {
jwt({ token, user }) {
if (user) token.role = user.role ?? "user"
return token
},
},Verify
A correct password signs the user in and auth() returns a session with the user; a wrong one returns CredentialsSignin.
// app/page.tsx (server component)
const session = await auth()
console.log(session?.user)Confirmed by raw.githubusercontent.com
How do I stop it coming back?
- Ban throw new Error inside authorize in code review; use return null or a CredentialsSignin subclass.
- Add one test that posts a wrong password and asserts the result is CredentialsSignin, so a Configuration regression fails in CI.
- Pin the exact next-auth beta in package.json, because beta releases can change error handling between versions.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine on the same stack: TaxiDex.