What this thread does
Do first: run npm ls next next-auth and use this NextAuth.js v4 path only when the app already uses next-auth@4.24.15.
Short answer
As of November 2026, this card pins NextAuth.js 4.24.15 for an existing Next.js App Router app. Email means passwordless links. Configure one shared adapter and auth options, then use getServerSession(authOptions) before protected reads and writes; client-side UI restrictions alone are not sufficient for security.
Choose / don't choose
- Database sessions: choose when immediate central revocation and a shared database are required; sign-out deletes the database session.
- JWT sessions: choose when avoiding a session lookup matters; early revocation needs additional state. Email tokens still require a database even with JWT sessions (email guide; session strategies).
Settings that matter
| Setting or flag | Value / default | Applies to | Source |
|---|---|---|---|
NEXTAUTH_URL | Canonical site origin; local development origin locally, public HTTPS origin in production | NextAuth 4.24.15 | source |
GoogleProvider({ clientId, clientSecret }) | Use the matching Google OAuth client; load both values only on the server | NextAuth 4.24.15 | source |
Google Authorized redirect URIs | Local development origin or production HTTPS origin followed by /api/auth/callback/google; register each exact URI | NextAuth v4 / Google OAuth | source |
EmailProvider({ server, from }) | SMTP transport and sender; maxAge: 24 * 60 * 60 seconds is the default link lifetime; install nodemailer | NextAuth 4.24.15 | source; provider source |
adapter; session.strategy | Configure a database adapter; "database" is the adapter-backed default, "jwt" otherwise | NextAuth 4.24.15 | source |
cookies.sessionToken.options | httpOnly: true, sameSite: "lax", path: "/"; retain built-in cookie policy | NextAuth 4.24.15 | source |
useSecureCookies | true on HTTPS; default false for local HTTP; keep production HTTPS | NextAuth 4.24.15 | source |
Cookie Domain | Omit for host-only scope; do not broaden to sibling subdomains by default | HTTP cookies / NextAuth v4 | source |
Order of operations
1. Create the auth handler at app/api/auth/[...nextauth]/route.ts with shared options; configure the adapter and both providers (v4 integration). 2. Register the provider callbacks for each environment. Configure the same stable NEXTAUTH_SECRET across replicas without exposing it to the browser (options). 3. In a server data-access function, await getServerSession(authOptions), reject a missing session, then enforce record ownership before querying account data. Repeat authorization in every Server Action and Route Handler before mutation; layouts may be reused during navigation (Next.js authorization). 4. Inspect Set-Cookie and the next request in the browser. Sign out, then request the account URL and mutation directly: both must reject access. The email provider default expires links after 24 hours; a redeemed token is single-use (lifetime; token discussion).
Known failures and fixes
| Error (short quote) | Cause | Fix | Source |
|---|---|---|---|
redirect_uri_mismatch | Requested redirect URI differs from the registered OAuth client URI | Compare scheme, hostname, port, case, path and trailing slash; fix the client registration and canonical URL | |
EMAIL_REQUIRES_ADAPTER_ERROR | Email provider lacks persistent verification-token storage | Configure the adapter and its tables; JWT session selection does not remove this requirement | source |
SIGNIN_EMAIL_ERROR / CALLBACK_EMAIL_ERROR | Email token generation or verification request failed; callback errors can occur during email sign-in | Double-check email settings | source |
Missing
- A patch-level Next.js compatibility claim for this legacy v4 integration is not established here; retain the application's supported lockfile.
Checked
2026-11-12; NextAuth.js 4.24.15 (July 20, 2026 release); sources read: linked provider, options, integration, error, Google and cookie references. A. Barth's RFC 6265 is dated April 2011. The independent January 2021 discussion records one-use token behavior, not current device evidence. No application commands executed.
Not for: selecting an authentication library; see better-auth-or-clerk-or-authjs-for-nextjs-auth-cost-lock-in-own-postgres.
Started from a post by @Auth.js, packaged by the editor. Original post