{"record":{"id":"987305062bb4b6b8","repo":"nextauthjs/next-auth","slug":"next-auth-next-is-deprecated-if-you-are-not-rea","errorCode":null,"errorMessage":"\"next-auth/next\" is deprecated. If you are not ready to migrate, keep using \"next-auth@4\".\nRead more on https://authjs.dev/getting-started/migrating-to-v5","messagePattern":"\"next-auth/next\" is deprecated\\. If you are not ready to migrate, keep using \"next-auth@4\"\\.\nRead more on https://authjs\\.dev/getting-started/migrating-to-v5","errorType":"exception","errorClass":"ReferenceError","httpStatus":null,"severity":"error","filePath":"packages/next-auth/src/next.ts","lineNumber":9,"sourceCode":"/**\n * :::warning Deprecated\n * This module is replaced in v5. Read more at: https://authjs.dev/getting-started/migrating-to-v5#authenticating-server-side\n * :::\n *\n * @module next\n */\n\nthrow new ReferenceError(\n  [\n    '\"next-auth/next\" is deprecated. If you are not ready to migrate, keep using \"next-auth@4\".',\n    \"Read more on https://authjs.dev/getting-started/migrating-to-v5\",\n  ].join(\"\\n\")\n)\n\nexport {}\n","sourceCodeStart":1,"sourceCodeEnd":17,"githubUrl":"https://github.com/nextauthjs/next-auth/blob/a1a16a5a7780488c7449feece410033f445d0b31/packages/next-auth/src/next.ts#L1-L17","documentation":"This error is thrown unconditionally when importing the 'next-auth/next' entry point in next-auth v5 (Auth.js). The module no longer exports getServerSession and friends; it exists only to tell developers the API moved to 'next-auth' core exports (auth, signIn, signOut). The library intentionally throws a ReferenceError at module load rather than silently behaving differently.","triggerScenarios":"Importing anything from \"next-auth/next\" (e.g. `import { getServerSession } from \"next-auth/next\"`) after upgrading to next-auth v5; the module's top-level throw fires as soon as the module is evaluated.","commonSituations":"Upgrading next-auth@4 to v5 (Auth.js) without updating imports; following old tutorials or Stack Overflow answers that use next-auth/next; partial migration where app router code still references the legacy entry point.","solutions":["Replace imports from \"next-auth/next\" with the root \"next-auth\" package, e.g. `import { auth } from \"next-auth\"` or `import { signIn, signOut } from \"next-auth\"`","Use `auth()` from \"next-auth\" inside server components/route handlers where you previously used getServerSession","Pin to next-auth@4 if you cannot migrate yet: `npm i next-auth@4`","Follow the official migration guide at https://authjs.dev/getting-started/migrating-to-v5"],"exampleFix":"// before\nimport { getServerSession } from \"next-auth/next\"\nconst session = await getServerSession(authOptions)\n// after\nimport { auth } from \"next-auth\"\nconst session = await auth()","handlingStrategy":"validation","validationCode":"// Fail fast with a clear message if the deprecated entry point is (transitively) imported\nconst deadEntry = process.env.NEXT_RUNTIME !== undefined\nif (process.env.NODE_ENV !== \"production\" && typeof require === \"function\") {\n  // ensure no module references next-auth/next\n  // e.g. grep in CI: ! grep -r \"next-auth/next\" src/\n}","typeGuard":"function isNextAuthNextImport(imp: string): boolean {\n  return imp === \"next-auth/next\" || imp.startsWith(\"next-auth/next/\")\n}","tryCatchPattern":"try {\n  const mod = await import(\"next-auth/next\")\n} catch (e) {\n  // ReferenceError: entry point removed in v5\n  const { auth } = await import(\"next-auth\")\n}","preventionTips":["Never import from \"next-auth/next\" in v5; use the root \"next-auth\" package","Add a CI grep/lint rule banning the string \"next-auth/next\"","Read the v5 migration guide before upgrading","Pin next-auth@4 if you cannot migrate immediately"],"tags":["deprecated","migration","nextjs","server-side"],"backgroundTag":"deprecated-module-import","analyzedSha":"a1a16a5a7780488c7449feece410033f445d0b31","analyzedAt":"2026-08-28T21:52:38.200Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}