Step 8

When you finally ready to deploy your React app (as we are right now), you can create a production bundle using the following command:

npm run build

This will generate an optimized build of your React application, ready to be deployed. The generated artifacts will be placed in the build.

To check it out locally, you should serve the content of the build folder (so don't directly open index.html). One of the easiest way to do this is to install serve and let it handle the rest:

npm install -g serve

Notice that I installed this package "globally".

After installation, serve your static site using the following command:

serve -s build

Note that you must be in the root of your application (zirectory-app folder) to run the above command.

By default, serve runs your site on port 5000.

The port can be adjusted using the -l or --listen flags:

serve -s build -l 4000

For more information, consult the documentation of serve.