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.
The index.html file is created after running next build.
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)
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.
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)
index.htmlSo 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);