Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

357
Views
How set a custom directory for pages in Next JS? (not src or root)

I'm encountering a problem when set a custom directory in Next JS.

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.

Instead i want to do it this way:

src
├── frontend
│   ├── pages
│   │   ├── index.tsx                         
│   │   ├── firstPage.tsx                     
│   │   ├── ...
│   │   components
│   │   ├── ...                   
├── backend
│   ├── ...   

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:

 "scripts": {
    "dev": "next ./src/frontend",
  },

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.

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?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Unfortunately, it seems Next.js officially supports only ./pages or ./src/pages directories. Tim explains his point of view over this decision in his comment in one of many issues requesting this option on Github see. More can be found also here and here.

However, you might want to check out this discussion, as Daniel's fork has option to look for pages in additiona directories.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!