+ 3

Next-Auth

Here is a button. SignIn is imported from Next-Auth. I am using next-auth 4 version. <Button ariaLabel="Sign in with Google" onClick={() => SignIn('google')} icon={<Image src={googleIcon} alt="Google icon" />} text="Continue with Google" isLoading={loadingStates.google} /> This is the provider in /pages/api/auth/[...nextauth].ts file GoogleProvider({ clientId: process.env.AUTH_GOOGLE_ID ?? '', clientSecret: process.env.AUTH_GOOGLE_SECRET ?? '', }), this is the callBack callbacks: { async signIn({ user, account }) { const provider = account?.provider; if (provider === 'google') { try { } catch (error) { console.error(`${account?.provider} sign-in error:`, error); return false; } } return true; }, so in try block i want to get a session id in the next-Auth that i get from localstorage. Here is the problem that next-auth is a server file i cannot access local storage in this file and i am not able to send sessionId through signIn method because it does not take the additional arguments. can anyone tell me how can i do it ?? I am again telling that i am using next-auth 4 version. I have read all the next-auth documentation but i have not got a single way to do it so please help me anyone. if you want more explanation. ask me i will provide.

2nd Dec 2024, 5:31 PM
Davinder Kumar
Davinder Kumar - avatar
1 Answer