Next.js Discord

Discord Forum

NextAuth callback handler returns null

Unanswered
Masai Lion posted this in #help-forum
Open in Discord
Masai LionOP
api/auth/[...nextauth]/route.js
import { handlers } from "@/lib/auth"
export const { GET, POST } = handlers

@/lib/auth.js
import NextAuth from "next-auth";
import Google from "next-auth/providers/google";

export const { signIn, signOut, auth, handlers } = NextAuth({
  providers: [Google],
});


Login Page
import { signIn } from "@/lib/auth";

export default function() {
  return (
    <form
      action={async () => {
        "use server";
        await signIn("google");
      }}
    >
      <button type="submit">Signin with Google</button>
    </form>
  );
}

0 Replies