<h1 dir="auto">Feature request</h1>
<h2 dir="auto">Is your feature request related to a problem? Please describe.</h2>
<p dir="auto">It isn't related to a problem. But if what I'm asking already exists its a good idea to let it more clear on the docs.</p>
<h2 dir="auto">Describe the solution you'd like</h2>
<p dir="auto">It will be awesome if we can add a config on <code class="notranslate">next.config</code> that allow us to add a ignored name folder to <code class="notranslate">/pages</code> that will not crawl that folder as an app page.<br>
The purpose of it is a way to create a components folder wich has the components that belong to a unique page and (probably) wont be reused again. That kind of practice let clear that this components belong only to that page and will be easier to add things like useMemo, React.memo and useCallback without pollute the root <code class="notranslate">/components</code> folder with never reused components.</p>
<p dir="auto">Something like:</p>
<p dir="auto">Folder:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="/pages
....  /customers
........  /components
........  index.js"><pre class="notranslate"><code class="notranslate">/pages
....  /customers
........  /components
........  index.js
</code></pre></div>
<p dir="auto">Config:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="module.exports = {
    notPage: ['components']
};"><pre class="notranslate"><code class="notranslate">module.exports = {
    notPage: ['components']
};
</code></pre></div>
<h2 dir="auto">Describe alternatives you've considered</h2>
<p dir="auto">It is possible to create a <code class="notranslate">/pages</code> components inside <code class="notranslate">root</code> <code class="notranslate">/components</code> folder and there add that kind of component.</p>
<h1 dir="auto">Feature request</h1>
<h2 dir="auto">Is your feature request related to a problem? Please describe.</h2>
<p dir="auto">There are many different methods of codebase organization in the wild and one popular one is to use an <code class="notranslate">index.js</code> file for the page component itself and surround it with sibling files for various subviews that are specific to that page.</p>
<p dir="auto">However, next doesn't support this kind of structure because it automatically assumes <em>all</em> files inside of <code class="notranslate">pages/</code> are real pages.</p>
<h2 dir="auto">Describe the solution you'd like</h2>
<p dir="auto">There already is precedent in the codebase for convention over configuration when it comes to filenaming:</p>
<ul dir="auto">
<li>the <code class="notranslate">[id].js</code> pattern for dynamic routing</li>
<li>the <code class="notranslate">_(app|document|error).js</code> pattern for overriding built-in pages</li>
</ul>
<p dir="auto">I propose extending the leading-underscore naming pattern such that any file inside <code class="notranslate">pages/</code> prefixed with an underscore will not be considered as a public page and can simply live in the folder.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="pages/
  index.js                  &lt;- page
  accounts/
    index.js                &lt;- page
    _constants.js           &lt;- not a page
    _modal.js               &lt;- not a page"><pre class="notranslate"><code class="notranslate">pages/
  index.js                  &lt;- page
  accounts/
    index.js                &lt;- page
    _constants.js           &lt;- not a page
    _modal.js               &lt;- not a page
</code></pre></div>
<h2 dir="auto">Describe alternatives you've considered</h2>
<p dir="auto">Another prefix I thought of was "$", e.g. <code class="notranslate">$constants.js</code> but this felt a little strange to write and actually is <a href="https://en.wikipedia.org/wiki/Filename" rel="nofollow">not supported in some filesystems</a>.</p>