Mendlark / Guides

Supabase "Invalid login credentials": how to fix it

A user types their email and password into your Lovable, Bolt or Cursor app and Supabase answers AuthApiError: Invalid login credentials (code invalid_credentials, HTTP 400). Sometimes it really is a typo. Often it isn't: the account lives in a different project, never had a password, or was never created at all.

Stuck on this? Get it fixed for €49.

Fixed in 48 hours or you don't pay. Launch deal for the first 5 customers (normally €79). You get the tested fix as a pull request, so nothing changes until you merge it.

Get it fixed for €49

1. Check you're looking at the right Supabase project

The most common cause in AI-built apps: preview and production point at different Supabase projects. The user signed up on the preview, and the live site checks a project where they don't exist. Open your live site, then compare the project URL it uses with the one in your dashboard:

// in the browser console on your live site
console.log(import.meta.env.VITE_SUPABASE_URL) // Vite / Lovable / Bolt
// Next.js: process.env.NEXT_PUBLIC_SUPABASE_URL

Then open Authentication → Users in that project and search for the email. No row means the account doesn't exist there. See env variables undefined in production if the value is missing.

2. The account has no password

In the Users list, look at the Provider column. If it says google, github or the user only ever used a magic link, there is no password to match, so every password login fails with invalid_credentials. Point them to the button they used to sign up, or let them set a password:

await supabase.auth.resetPasswordForEmail(email, {
  redirectTo: `${window.location.origin}/update-password`,
})

On the /update-password page, call supabase.auth.updateUser({ password }) once the user lands back signed in.

3. The signup never really happened

With email confirmation on, calling signUp for an email that already exists does not return an error, so people don't learn about existing accounts. It returns a user with an empty identities array, and the password they just typed is never saved. Your app shows "Check your email", nothing arrives, and later the login fails. Detect it:

const { data, error } = await supabase.auth.signUp({ email, password })
if (!error && data.user?.identities?.length === 0) {
  setMessage('You already have an account. Log in or reset your password.')
}

4. "Email not confirmed" is a different error

If Supabase returns email_not_confirmed instead, the password is fine but the user hasn't clicked the confirmation link. Offer a resend button rather than telling them their password is wrong:

if (error?.code === 'email_not_confirmed') {
  await supabase.auth.resend({ type: 'signup', email })
  setMessage('Please confirm your email first. We just sent a new link.')
}

If those emails never arrive, see Supabase confirmation emails not arriving.

5. Small things that break matching

  • Trailing spaces from mobile keyboards or autofill: email.trim() before sending. Don't trim passwords.
  • The form sends the wrong field (a username or a stale state value) as email. Log what you send, never the password itself.
  • A test user created with "Add user" in the dashboard but with "Auto confirm" off.

6. Show a safe message

Keep the visible message vague on purpose, so it doesn't reveal which emails have accounts, and branch on error.code, not the message text:

if (error?.code === 'invalid_credentials') {
  setMessage('Email or password is incorrect. Forgot your password?')
}

Repeated failed attempts can trigger over_request_rate_limit (HTTP 429). Disable the button while a login request is running.

Quick checklist

  • Live site and dashboard point at the same Supabase project
  • User exists in Authentication → Users, with an email provider
  • Empty identities after signUp means "already registered"
  • email_not_confirmed: offer a resend, not "wrong password"
  • Trim the email, branch on error.code

Stuck on this? Get it fixed for €49.

Fixed in 48 hours or you don't pay. Launch deal for the first 5 customers (normally €79). You get the tested fix as a pull request, so nothing changes until you merge it.

Get it fixed for €49

Still stuck?

Mendlark fixes this kind of problem for a fixed €49 (launch price, normally €79). We agree the problem first, test the fix and send it as a pull request, so nothing changes in your app until you merge it. If we can't fix it, you don't pay. Get the €49 fix, or start with a free scan.

Not sure what else is wrong? Paste your app link into the free instant check and get a plain-English list of problems in seconds.