Replies: 2 comments 1 reply
-
You only need to use 'use client' when using the app directory of Next.js, because all components in the app directory are server components by default. Don't post to http://localhost:8000/auth/login. Just use the signIn function. If you're using NextAuth.js right, you should be able to log with console.log inside import { signIn } from "next-auth/react"
<button onClick={() => signIn()}>Sign in</button> |
Beta Was this translation helpful? Give feedback.
0 replies
-
but the console log here doesnt work at all?? import { authConfig } from '@/shared/lib/auth.config';
import NextAuth from 'next-auth';
import Credentials from 'next-auth/providers/credentials';
import { z } from 'zod';
export const {
handlers: { GET, POST },
auth,
signIn,
signOut,
} = NextAuth({
...authConfig,
providers: [
Credentials({
async authorize(credentials) {
console.log({ credentials });
const parsedCredentials = z
.object({ email: z.string().email(), password: z.string().min(6) })
.safeParse(credentials);
// if (credentials.password !== 'password') {
// return null;
// // Return an object that will pass error information through to the client-side.
// // throw Error(
// // JSON.stringify({ errors: 'Invalid Credentials', status: false })
// // );
// }
return {
id: 'hello',
};
},
}),
],
pages: {
signIn: '/login',
},
}); |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Im new to NextAuth.js and im trying to explore it but i can't see any information what is happening behind the [...nextauth].js even in
authorize
method even i added "use client" is there any way to that?Beta Was this translation helpful? Give feedback.
All reactions