When I created a next.js app using npx create-next-app
there is 2 js files named app and document leading with an Underscore what is that for?
The files are like this:
▼ pages
_app.js
_document.js
When I created a next.js app using npx create-next-app
there is 2 js files named app and document leading with an Underscore what is that for?
The files are like this:
▼ pages
_app.js
_document.js
2
Answers
By naming these files with an underscore prefix, Next.js indicates that they are special files that should not be directly accessed by the user. Instead, they are meant to be used as templates or boilerplate codes that can be modified to fit the specific needs of your application.
It is a matter of convention.
_
indicates that the file is partial and not supposed to be exposed as a page to the user.Here is a quote from one of the contributors of Next.js.
Source