Home > front end >  Protected routes in next js
Protected routes in next js

Time:05-03

I have two types of user . when user login i need to redirect them based on their role . Also protect routes. Only login user can go to specific routes based on their role. how this can be done in next js

CodePudding user response:

You can get the auth token and create a serverSideProps https://nextjs.org/docs/basic-features/data-fetching/get-server-side-props to redirect the user by role.

CodePudding user response:

when the user logs into your app, you can save his permission in cookies and then get his permission via serverSideProps, and render the page according to the user.

  • Related