Minimal v5 App Router Shape
This is a migration reference only, not part of the runnable v4 Pages Router path. Complete the provider and callbacks using the current v5 docs for your release.
File shape: `auth.ts`
import NextAuth from "next-auth";
import Google from "next-auth/providers/google";
import Credentials from "next-auth/providers/credentials";
export const { handlers, auth, signIn, signOut } = NextAuth({
providers: [
Google,
Credentials({
credentials: {
email: { label: "Email", type: "email" },
password: { label: "Password", type: "password" },
},
async authorize(credentials) {
if (!credentials?.email || !credentials?.password) return null;
const response = await fetch(`${process.env.AUTH_API_URL}/auth/login`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ email: credentials.email, password: credentials.password }),
cache: "no-store",
});
if (!response.ok) return null;
const result = await response.json();
const user = result?.user;
if (!user?.id || !user?.email) return null;
return { id: String(user.id), name: user.name ?? null, email: user.email };
},
}),
],
});
// app/api/auth/[...nextauth]/route.ts:
// export const { GET, POST } = handlers;💡 This shows the export shape only. Use the actual current v5 documentation for complete callbacks, session settings, and your exact Next.js version.