How do you handle different page "layout (and actions)" for a specific component in the page?
Unanswered
Brown bear posted this in #help-forum
Brown bearOP
I am building on next.js 13 and I came up with a particular problem that bugged for a while and wondered what would be the proper way to tackle it. So all my users are registered and each one of the have a different role. But all can interact with the same page but they won't be shown the same page (here it will be only a button label and action trigger (that would be different in a component). And I was wondering what is the best way to handle such behavior? Should I create a new component for each type of user that will handle it on its own? How would you achieve this? Thank you
5 Replies
@Brown bear I am building on next.js 13 and I came up with a particular problem that bugged for a while and wondered what would be the proper way to tackle it. So all my users are registered and each one of the have a different role. But all can interact with the same page but they won't be shown the same page (here it will be only a button label and action trigger (that would be different in a component). And I was wondering what is the best way to handle such behavior? Should I create a new component for each type of user that will handle it on its own? How would you achieve this? Thank you
put the role type in the header then on that "page"'s server component, check the header and do conditional rendering
it will be dynamically rendered ofc
Brown bearOP
If I put the role in the header of the component, what will be the use of it since the component is the one that determines the what to display?
@Brown bear If I put the role in the header of the component, what will be the use of it since the component is the one that determines the what to display?
No, i meant the header of the request object... not the header component
Or if you put the role inside a session object you can check that to conditionally render the components