title: How set a custom directory for pages in Next JS? (not src or root)
body: <p>I'm encountering a problem when set a custom directory in Next JS.</p>
  <p>I know that by default, the pages directory should be in root or the src directory, but this option doesn't suit me because I can't hide all the frontend files in one directory.</p>
  <p>Instead i want to do it this way:</p>
  <pre><code>src
  ├── frontend
  │   ├── pages
  │   │   ├── index.tsx                         
  │   │   ├── firstPage.tsx                     
  │   │   ├── ...
  │   │   components
  │   │   ├── ...                   
  ├── backend
  │   ├── ...   
  </code></pre>
  <p>However Next JS doesn't allow me to do this and I don't understand why, I've tried looking for possibilities for this, e.g:</p>
  <pre><code> &quot;scripts&quot;: {
      &quot;dev&quot;: &quot;next ./src/frontend&quot;,
    },
  </code></pre>
  <p>This works, but it's still not what I need.  With this approach, next creates tsconfig, .next, etc directly in the frontend directory, which looks weird, I would like to keep the configuration files in the root directory.</p>
  <p>It seems that for some reason I can't have pages directory inside frontend directory, but I can't figure out what this has to do with. If this is really the case could you tell me why?</p>