Next.js Discord

Discord Forum

Should middleware be used for role-based routing?

Unanswered
Northeast Congo Lion posted this in #help-forum
Open in Discord
Northeast Congo LionOP
My last work with Next.js professionally was with version 12. In that project, I had used a higher order component which wrapped all in the pages in the _app.tsx file and had used next-redux-wrapper and next-redux-cookie-wrapper for storing user details to handle role-based routing. Now with the latest version of Next.js out where middleware bypass issue has been resolved, should I use the middleware to handle role-based routing or should I use a higher order server component to do this? Note that I am planning to use cookies-next or iron-session for storing access token, refresh token, and user object sent from a separate back-end app upon log in.

0 Replies