Important v5 Differences
Auth.js v5 commonly defines auth.ts with const { handlers, auth, signIn, signOut } = NextAuth(config). In the App Router, app/api/auth/[...nextauth]/route.ts exports the GET and POST handlers. Server-side session retrieval commonly uses auth(). In newer APIs, redirectTo is preferred over the deprecated callbackUrl option. Consult the migration guide and do not mix v4 and v5 code.
Keep the main implementation consistent
The complete Pages Router code in this tutorial targets NextAuth v4. Use the v5 docs end-to-end if your installed package is v5.