Auth.js · build / TypeScript

v4 code in a v5 app (getServerSession, authOptions)

what it looks like
Module '"next-auth"' has no exported member 'NextAuthOptions'. · getServerSession(authOptions)

What it means

Your AI agent wrote NextAuth v4 code. A lot of tutorials and training data are from v4, so agents mix the two APIs unless you tell them which version you use.

Common causes

  • getServerSession(authOptions) and next-auth/next imports
  • NextAuthOptions (renamed NextAuthConfig)
  • export { default } from "next-auth/middleware"
  • @next-auth/prisma-adapter (now @auth/prisma-adapter)

How to fix it

  1. Call auth() from your auth.ts everywhere on the server
  2. Export auth as proxy in proxy.ts (Next.js 16 renamed middleware.ts)
  3. Add a rule telling your agent the project uses Auth.js v5 and to check package.json before writing auth code
src/app/dashboard/page.tsx
- import { getServerSession } from "next-auth/next"
- const session = await getServerSession(authOptions)
+ import { auth } from "@/auth"
+ const session = await auth()

works with next-auth 5.0.0-beta.32 · @auth/core 0.41.3 · Next.js 16.4.3last verified

prevent it · 00-workflow.mdc (free Cursor Rules Pack): Makes the agent check the installed next-auth version in package.json before writing auth code, so v4 examples don't land in a v5 app.

Prompt for Cursor or Claude Code

This project uses Auth.js v5 (next-auth@5). Search for getServerSession, authOptions, NextAuthOptions, next-auth/next, next-auth/middleware, getToken and @next-auth/ imports and migrate each one to the v5 auth() API. List every file you change.

Not quite your error? Paste yours into the free VibeBoot Doctor or browse the Auth.js error fixer.

next: skip the next one

Skip the setup. The VibeBoot SaaS Starter ships Auth.js v5 already wired (GitHub sign-in, optional email magic links, Prisma adapter), plus Stripe and a database on Next.js 16.4.3. $49, one-time.

14-day money-back guarantee · lifetime updates

$ fixed it? get the next one first

New fixes for what AI agents break, by email.

When we add a fix or a Cursor rule for a new Next.js, Auth.js, Prisma or Stripe break, it goes out in the VibeBoot newsletter. Free, occasional, unsubscribe in one click.

Subscribe free