skip to Main Content

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


  1. 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.

    Login or Signup to reply.
  2. 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.

    We actually use the underscore (_) prefix for ‘private’ (internal, but not actually secret) pages, based on common convention of underscores often being used to denote that.

    Source

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search