Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

363
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda