Production Mode in the NextJS Framework
Production mode is intended for running the project on a hosting service. The main goal of this mode is to ensure maximum performance and security of the project, as well as to reduce the volume of loaded files to save system memory.
Key features of production mode:
- Code Optimization - before running in production, the code is compiled. For example, JavaScript and CSS are minified to reduce their size and speed up page loading.
- Static Generation - the framework pre-generates pages, which speeds up their loading on the site.
- Image Optimization, where images are automatically compressed and adjusted for different screen sizes and devices.
- Removal of Debug Information - all code for debugging errors is removed from the browser pages. This is necessary for the secure operation of the project and to hide information about the file structure from users.
- No Hot Reload - unlike development mode, there is no automatic reload on every change made.
Production mode is started with two commands. First, you need to perform a production build of the project:
npm run build
And then run the built project:
npm start
After starting the project, you will see information about the main structure of the project. Special symbols mark the types of project content - static and dynamic. At the moment, we only have static content.
Try running the project in production mode.
Turn off production mode and turn on development mode. In the following lessons, we will work specifically in this mode.