how to make multiple pages under one route with private folders
Answered
Pteromalid wasp posted this in #help-forum
Pteromalid waspOP
I think it is easier if I show you my folder arrangement, so what I am trying to accomplish is to show the
if it is, how do I redirect to each one?
home/page.tsx depending on what user is logged in, but I want to have the admin and employee folder as private so the url only shows /home, is it possible to do this?if it is, how do I redirect to each one?
Answered by B33fb0n3
yes, you can rewrite the url depending on the permissions of the user. Create a middleware, check the permissions and use the rewrite function to rewrite (url won't change, page content will change).
An easier thing is to split your pages into parallel routes. Like that you have an admin slot and a user slot. Check inside the page the permissions and depending on that you either show the admin slot or the user slot. You can find one example for that here: https://nextjs.org/docs/app/building-your-application/routing/parallel-routes#conditional-routes
An easier thing is to split your pages into parallel routes. Like that you have an admin slot and a user slot. Check inside the page the permissions and depending on that you either show the admin slot or the user slot. You can find one example for that here: https://nextjs.org/docs/app/building-your-application/routing/parallel-routes#conditional-routes
4 Replies
@Pteromalid wasp I think it is easier if I show you my folder arrangement, so what I am trying to accomplish is to show the `home/page.tsx` depending on what user is logged in, but I want to have the admin and employee folder as private so the url only shows `/home`, is it possible to do this?
if it is, how do I redirect to each one?
yes, you can rewrite the url depending on the permissions of the user. Create a middleware, check the permissions and use the rewrite function to rewrite (url won't change, page content will change).
An easier thing is to split your pages into parallel routes. Like that you have an admin slot and a user slot. Check inside the page the permissions and depending on that you either show the admin slot or the user slot. You can find one example for that here: https://nextjs.org/docs/app/building-your-application/routing/parallel-routes#conditional-routes
An easier thing is to split your pages into parallel routes. Like that you have an admin slot and a user slot. Check inside the page the permissions and depending on that you either show the admin slot or the user slot. You can find one example for that here: https://nextjs.org/docs/app/building-your-application/routing/parallel-routes#conditional-routes
Answer
happy to help