Auth.js v5 in Next.js App Router
// auth.ts
import NextAuth from 'next-auth';
import GitHub from 'next-auth/providers/github';
export const { handlers, signIn, signOut, auth } = NextAuth({
providers: [GitHub],
callbacks: {
authorized: async ({ auth }) => {
return !!auth; // Logged in users can access protected pages
}
}
});