Is it possible to have a page name and, a folder name that consists of dynamic pages, to be the same?

68 Views Asked by At

enter image description here

In the above image, I have a page named "Movies" and I also have a folder named movies

I want to navigate in a way that if the address bar has the url of '/movies' it should take me to the "movies.js" page and only if the address is something like '/movies/123', it should take me to the page with that specific ID.

But it doesn't seem to work that way. When I navigate to '/movies' it takes me to the movies.js page but after i navigate to '/movies/123' and then go back, it takes me to a '/movies' but the movies.js page is not rendered. I instead see a blank screen. Please tell me if it's possible to have a page name and a folder name to be same in Next JS.

1

There are 1 best solutions below

2
devpolo On

Try adding movies/index.js to your movies folder.

More info on the next documentation