While reading through the next.js documentation, I came across an interesting point.
- The documentation mentions that index.js serves as the root of the directory. This means that if I type
/blog
in the URL, it will lead me to thepages/blog/index.js
file.
However, I have a dilemma with a file called pages/blog/subcomponent.js
. I do not want users to be able to access /blog/subcomponent
because it is meant to be a subcomponent. How can I prevent this?
Another article from next.js suggests using page.js
instead of index.js
, making only page.js
publicly accessible.
- Does this imply that files other than
page.js
are inaccessible? I'm feeling quite confused about this. Any clarification would be greatly appreciated.