Next.js Discord

Discord Forum

Page Reloads in Next Auth

Unanswered
Masai Lion posted this in #help-forum
Open in Discord
Avatar
Masai LionOP
I am using next auth for authentication. When login is successful it redirects to another page. But before redirecting the login page reloads and then only it redirects to another page.How to stop this reloading behaviours.#nextauth
githubrepo:- https://github.com/drb1010/auth-demo

4 Replies

Avatar
Santhosh Prabhakaran
After changing the isLoggedIn state, the useEffect runs again because of the dependancy array.
Avatar
Masai LionOP
still the problem exists after removing dependency from useEffect.Please help me.
username:admin@example.com
pwd:- 123
Avatar
Santhosh Prabhakaran
Instead of using the state try to use the session itself to validate
Avatar
Masai LionOP
i am validating in root component so i cant use useSession hook.can you give me some idea to achive this using getSession