npm run build creates a build directory with a production build of your app. Set up your favorite HTTP server so that a visitor to your site is served index.html, and requests to static paths like /static/js/main.<hash>.js are served with the contents of the /static/js/main.<hash>.js file.
Static Server
For environments using Node, the easiest way to handle this would be to install serve and let it handle the rest:
npm install -g serve
serve -s build
The last command shown above will serve your static site on the port 5000. Like many of serve’s internal settings, the port can be adjusted using the -l or --listen flags:
serve -s build -l 4000
Run this command to get a full list of the options available:
serve -h
Other Solutions
You don’t necessarily need a static server in order to run a Create React App project in production. It also works well when integrated into an existing server side app.
Express
Express is a fast, unopinionated, minimalist web framework for Node.js. Here’s a programmatic example: