🎓 A1Learner
🔍
0 of 50 lessons completed

Next.js Static vs Dynamic Rendering

Some pages are built once. Others are built fresh for each reader. The build tells you which is which.

A static page answers 200

The book page is static. The check asks for it, and the answer is 200.

curl -s -o /dev/null -w "%{http_code}\n" http://localhost:3110/books/dune

A dynamic page answers 200 too

The search page is partial. It also answers 200. The mark is about how the page is built, not whether it answers.

curl -s -o /dev/null -w "%{http_code}\n" "http://localhost:3110/search?q=dune"

Example

npm run build

Key points

  • Static: a page built once, at build time. Every reader gets the same file.
  • Dynamic: a page built fresh for each request. The reader gets a new answer each time.
  • The build prints a mark per route. A circle means static. A half circle means partial prerender.
  • Partial prerender: the static shell is built once, and the live part streams in per request.
  • /search and /signin are partial. They read the request, so they cannot be fully static.
  • /cached is partial too. It shows a cached count and a live time on the same page.

In this example, the build prints one line per route. The home page and the two known book pages carry the circle mark, so they are static. The search page, the sign-in page, and the cached page carry the half circle mark, so they are partial. The cached row also shows 1h and 1d, the fresh time and the expiry time. The two book pages under /books/[id] are listed one by one. No size column appears, because the 16.4 build does not print one.

Note

The 16.4 build prints no size summary. There is no file size column in the route table.

Try it Yourself

Edit the code, then press Run.

Running is simulated · TypeScript Playground

Exercise

What does the circle mark mean in the route table?