Q:

How to generate build files in next js

I am learning basic next js. If we run npm run build create-react-app will generate build folder index.html and bundle files. In next js. It doesn't create any build file. How will I deploy next js project in the server 
.next folder

A:

Make sure your package.json file scripts appear as follow:

    "scripts": { 
      "dev": "next", # development
      "build": "next build", # build nextapp to .next folder
      "start": "next start", # start nextjs server for .next build folder
      "prod": "next export" # export nextjs files as bundle like in react app
   }

Nodejs needs to be set to production first in .env or use it as below.

   npm run build # to build the nextjs in .nextfolder
   NODE_ENV=production npm run start # set NODE_ENV to production and start server 

However, this will be on default port 3000. You can change the port to serve traffic direct to port 80 and 443 as "start": "next start -p 80", or use advanced reverse proxy like nginx to server your app to the world. I would recommend nginx because it multithreads and have cool security features you can implement.
reference: https://github.com/zeit/next.js#production-deployment

