I want to make authentication. if the user is not logged in it will be redirected to the login page. I added that condition in the Provider file and implemented it in _app.js. after I added this file: const reds = () => { if(typeof window !== 'undefined'){ if(!user){ window.location.href = '/login' }else if(pathname === '/login' && user){ window.location.href = '/' }else{ window.location.href = '/' } } } The website page will always reload .....
Originally asked by Ardhi Cho on Stack Exchange (stackoverflow) (CC BY-SA 4.0).