Auth.js Identity Provider Integration

Auth.js (NextAuth) Suspicious Login Detection

Check login risk inside the Auth.js (NextAuth) Credentials authorize function and refuse risky sign-ins before a session exists.

Install command

npm install loginllama

Add LoginLlama to Auth.js in one call

Call LoginLlama from your Auth.js login handler before you create the session. Send the email, IP, and user agent, then allow, challenge, or block based on the returned risk score.

Auth.js login check
// Install: npm install loginllama
// auth.ts
import NextAuth, { CredentialsSignin } from 'next-auth';
import Credentials from 'next-auth/providers/credentials';
import { LoginLlama } from 'loginllama';
import { verifyPassword } from './users'; // your own user lookup

const loginllama = new LoginLlama({
  apiKey: process.env.LOGINLLAMA_API_KEY!
});

class RiskySignIn extends CredentialsSignin {
  code = 'risky_sign_in';
}

export const { handlers, auth, signIn, signOut } = NextAuth({
  providers: [
    Credentials({
      credentials: { email: {}, password: {} },
      async authorize(credentials, request) {
        const email = String(credentials.email);
        const user = await verifyPassword(email, String(credentials.password));
        if (!user) return null;

        // Auth.js hands over the original request, so the IP and
        // User-Agent come from its headers.
        // Fail open: an outage lets the sign-in through.
        const result = await loginllama
          .check(email, { request })
          .catch(() => null);
        if (result && result.risk_score > 7) throw new RiskySignIn();

        return user;
      }
    })
  ]
});

Why teams choose LoginLlama for Auth.js

Score every login in under 100ms

Detect VPNs, proxies, and TOR exit nodes

Explain why a login is risky with clear risk reasons

Catch errors from the check and logins go ahead during an outage

How it works

Step 1

Install or connect LoginLlama

Choose the SDK or integration point that fits your auth flow and add your API key.

Step 2

Check risk at login time

Send the email, IP, and device context before completing authentication.

Step 3

Act on the risk score

Allow, challenge, or block the login based on risk score and reasons.

Signals we analyze

New device or browser fingerprints

Impossible travel and velocity checks

Bot-like login bursts and credential stuffing

Geo anomalies and risky IP reputation

Works well with your Auth.js stack

NextAuth v5Credentials providerNext.js App Router

Auth.js login security FAQ

How do I add suspicious login detection to Auth.js?

Install LoginLlama with `npm install loginllama`, then call the risk check from your Auth.js login handler before you create the session. Send the user's email, IP address, and user agent, and branch on the returned risk score.

Will LoginLlama slow down Auth.js logins?

No. Risk scoring returns in under 100ms. If LoginLlama is unreachable the check throws an error, so catch it and let the Auth.js login go ahead. An outage then never blocks a real user.

What does LoginLlama detect on Auth.js logins?

New devices and browser fingerprints, impossible travel and login velocity, credential-stuffing bursts, and traffic from VPNs, proxies, TOR exit nodes, and high-risk IPs — each returned with a clear, human-readable reason code.

Does LoginLlama work with NextAuth v5, Credentials provider, Next.js App Router?

Yes. LoginLlama runs at the login step itself, so it works alongside NextAuth v5, Credentials provider, Next.js App Router and the rest of your Auth.js stack without replacing your existing authentication provider.

Other integrations

LoginLlama works with the same single API call across every stack.

Auth.js login protection

Protect Auth.js users from suspicious logins

Add LoginLlama in minutes and block risky logins in real time.

Start Free