Next.js Discord

Discord Forum

How to handle params route

Unanswered
West African Crocodile posted this in #help-forum
Open in Discord
Avatar
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

2 Replies

Avatar
Hassib
For creating dynamic routes, you should create a directory containing brackets and params inside the brackets, like this:

/profile
__/[username]
_____page.tsx