Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

264
Vistas
How does Next JS application works on browser even without .html file in folder structure?

Sorry if this is some stupid question But How does applications built in NextJS communicate with browsers as there is no .html file in the folder structure after creating npx create-next-app.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

The index.html file is created after running next build.

the files

The code that you write for Next.js is kind of an abstraction of the website you want to serve in the end.

That means you are writing Javascript code in an easy, convenient way, which has to follow the rules that Next.js has specified. Then you are telling Next.js to compile your code (next build), and Next.js creates the actual website based on your Javascript code.

The website files are created inside the folder /.next, the location of the index.html is /.next/server/pages/index.html. (see Next.js Build API)

the server

Next.js also provides its own node server, so if you call next start (after next build) it will start its own server, which just knows where to look for the files.

Next.js also defines some routing behind the scenes (based on your /pages folder), which is (kind of) the reason why you are not seeing any index.html in the address bar of the browser.

static files

If you are using next export instead of next start, then Next.js will create static files, and you will find a folder which contains .html files and all the stuff that you are probably were expecting to see, and which can be served by some other static file server. (For this you have to remove as least the <Image> from the project created by create-next-app, because of the limitations of next export)

remark about index.html

So we found where Next.js creates an index.html file, but also note that - while it makes sense to follow conventions - it would actually not even be necessary to have an index.html file if you are writing your own server, e.g.:

// - save as 'server.js',
// - run 'node server.js'
// - open 'http://localhost:8888/abc' in the browser

const http = require("http");
const url = require("url");

http.createServer(function(request, response) {
    var uri = url.parse(request.url).pathname;
    response.writeHead(200);
    response.write('<html><body>you called the url:' + request.url + '</body></html>');
    response.end();
}).listen(8888);
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda