How to handle params route
Unanswered
West African Crocodile posted this in #help-forum

West African CrocodileOP
Hi all,
How can I create route based on params like this :
/ -> index
/[username] -> username ?
Can I create two page.tsx and [username].tsx or I have to create only one page and check if there is no username for rendering index ?
In the past I used the pages folder and I know that we can do this but I don't find how with the app folder
How can I create route based on params like this :
/ -> index
/[username] -> username ?
Can I create two page.tsx and [username].tsx or I have to create only one page and check if there is no username for rendering index ?
In the past I used the pages folder and I know that we can do this but I don't find how with the app folder
2 Replies

Hi, here's the resource, it might help you.
https://nextjs.org/docs/app/building-your-application/routing/dynamic-routes
https://nextjs.org/docs/app/building-your-application/routing/dynamic-routes
For creating dynamic routes, you should create a directory containing brackets and params inside the brackets, like this:
/profile
__/[username]
_____page.tsx