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

201
Visualizações
Use index.js file in Next.js as homepage or only as starting point?

I wonder if I should implement my homepage directly inside the index.js file, or if I should create a seperate "home-page.js" file in the pages folder. Is the index.js file merely the starting point for the application or should I use it as a page itself? Or should I just redirect from index.js to my homepage? What are the different use cases for the index.js file in next.js vs react.js? I do not have any experiences and would like to hear some best practices or things to look out for.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

(I assume that you mean the Next.js file /pages/index.js)

You should use the Next.js /pages/index.js file as a page itself (1), i.e. as the page for the route http://localhost:3000, just the same as you would use e.g. /pages/about.js for the route http://localhost:3000/about.

The index.js files in Next.Js and in pure React are actually completely different, unrelated files:

  1. React index.js is the entry point for the apps javascript execution (or "starting point" how you called it).
  2. Next.js pages/index.js is the default route. It corresponds to the index.html of static webages, i.e. the page that comes up if you type e.g. http://localhost:3000 (without any page name) in the browsers address bar.

Next.js doesn't have any "entry point index.js" file at all (in the folders you are editing), instead all the final .js files will only be generated inside the .next folder when you start next build.

See also:

  • How does Next JS application works on browser even without .html file in folder structure?)
  • Why does create-react-app creates both App.js and index.js?

(1) I don't have any opinion about if you should use the /index.js directly, or redirect to e.g. /home, or avoid using /index.js altogether. Here I just try to explain what the /index.js file does, because I think that is what the question was actually asking.

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