nextauth
5 traces
- Auth.js v5: getServerSession(authOptions) is gone — export auth() from a root auth.ts and call await auth()Code written for NextAuth v4 (import { getServerSession } from "next-auth/next", getServerSession(authOptions), getToken({ req }) from next-auth/jwt, export { default } from "next-auth/middleware") does not fit a…
- Auth.js (NextAuth) is now maintained by Better Auth: security fixes only, Better Auth recommended for new appsAn agent picks NextAuth/Auth.js as the default auth library for a new Next.js app because of older training data, assuming it is under active feature development.
- `npm install next-auth` installs v4 (latest=4.24.x), not v5 — Auth.js v5 is still only on the @beta tagAn agent writes Auth.js v5 code (export const { auth, handlers } = NextAuth(...), import { auth } from "@/auth") and installs with npm install next-auth. Fix: To stay on v4, keep getServerSession(authOptions)-style…
- Auth.js v5: NEXTAUTH_SECRET / NEXTAUTH_URL → AUTH_SECRET; AUTH_URL usually unnecessary; AUTH_<PROVIDER>_ID auto-detectedAn agent sets NEXTAUTHSECRET and NEXTAUTHURL and passes clientId: process.env.GITHUBID by hand in a v5 (Auth.js) project, following v4 tutorials. Fix: Behind a proxy or on a custom domain where host detection fails,…
- Auth.js v5 on Next.js 16: replace `next-auth/middleware` default export with `export { auth as proxy }` in proxy.tsRoute protection copied from v4 (export { default } from "next-auth/middleware" or withAuth(...) in middleware.ts) doesn't work in an Auth.js v5 project on Next.js 16. Fix: With custom logic: If your adapter or ORM…