CHAPTER 5Building
Building your project is done through a package.json
script called build
, so:
bun run build
The output is something like:
$ next build
▲ Next.js 14.2.3
Creating an optimized production build ...
✓ Compiled successfully
✓ Linting and checking validity of types
✓ Collecting page data
✓ Generating static pages (5/5)
✓ Collecting build traces
✓ Finalizing page optimization
Route (app) Size First Load JS
┌ ○ / 5.29 kB 92.2 kB
└ ○ /_not-found 871 B 87.8 kB
+ First Load JS shared by all 87 kB
├ chunks/23-0627c91053ca9399.js 31.5 kB
├ chunks/fd9d1056-2821b0f0cabcd8bd.js 53.6 kB
└ other shared chunks (total) 1.86 kB
○ (Static) prerendered as static content
In this build step, NextJS gives us information about what routes are rendered statically or dynamically:
○ (Static) prerendered as static content
● (SSG) prerendered as static HTML (uses getStaticProps)
λ (Dynamic) server-rendered on demand using Node.js
"Static content" is any response that your app generates that is not HTML (API endpoints), "SSG" is for HTML files, and "Dynamic" for server-rendered pages.
Deploying
Having built the project, you can start the production version by launching a Node server with the compiled code by doing:
bun run start
The directory containing the compiled project is called .next
and it is quite large.