Closed dhruvkaushik305 closed 3 weeks ago
The signin method from auth.ts
is meant for server actions. For client components keep using the signIn
method imported from next-auth/react
Alright, but as i mentioned it isn't working on the server side either.
Couldn't see that in the reproduction.
Maybe check out https://github.com/nextauthjs/next-auth-example
which has a deployed/working example.
Environment
Reproduction URL
https://github.com/dhruvkaushik305/Dkode/blob/main/apps/web/app/_components/Navbar.tsx
Describe the issue
Following the docs, the initialization of the auth.ts itself feels weird as i am seeing typescript errors
The inferred type of 'signIn' cannot be named without a reference to '.pnpm/@auth+core@0.34.2/node_modules/@auth/core/providers'. This is likely not portable. A type annotation is necessary.ts(2742)
Ignoring that i created the signIn button and when using it server side, the router pushes a/?
and then redirects to/
without even showing the signinPage. I tried experimenting by making it client side, but nextJs is giving an error then thatError: headers was called outside a request scope. Read more: https://nextjs.org/docs/messages/next-dynamic-api-wrong-context
How to reproduce
Install the dependencies and then hit the dev server, try clicking the signIn button
Expected behavior
It should render the signIn page