Skip to content
Advertisement

Tag: next.js

Nested routes authentication in NextJs

Is there any way we can Authenticate all the nested routes ? In my project I have routes which needs authentication and routes which can be accessible without authentication. For eg. /admin => needs authentication /admin/posts => needs authentication /admin/posts/1 => needs authentication /admin/users => needs authentication and so on.. /view => can access without authentication /view/songs => can access

NextJs doesn’t rerun scripts

When I use the <Link> tag in NextJs to navigate between pages it doesn’t rerun my scripts after changing pages. It only runs the scripts after the first page load or when I press reload. When using plain <a> tags instead, it works fine because the page reloads after each navigation. As far as I can tell this happens because

Persist the login state in Next js using localstorage

I’m writing an authentication application in Next Js (v12.2.5). The application also uses React (v18.2.0). The problem is with persisting the authentication state. When the browser is refreshed, the login session is killed. Why is this happening even though I am getting and setting the token in the local storage. I would like to persist the login session to survive

Advertisement