FE3: Server rendering with Next.js

Lesson 1 of 5 ยท reading 15โ€“25 minutes; practice and project time is on the module page

Where pages are rendered

๐ŸŽฏYou'll be able to

Choose client, server, static or incremental rendering for each page, and justify it.

๐Ÿ The everyday picture

A restaurant can serve a dish cooked fresh to order, keep some ready-made on a warm counter, or give you ingredients to cook at your table. Each suits different dishes, crowds and waiting times.

๐Ÿ“˜What it really is

๐Ÿ“A worked example

Kirana Express pages and their rendering choices:

Page Choice Why
Home and store pages Static, revalidate every hour Same for everyone; should be fast and searchable
Product pages (5,000) Static, revalidate on price change Searchable; prices change a few times a day
Search results Server-rendered per request Depends on the query
Cart and checkout Client-rendered inside a server layout Personal; heavy interaction
Order tracking Server-rendered shell, live updates in the browser Personal and live

Moving product pages from client rendering to static with revalidation cut the time until the product appeared on a mid-range phone over 4G from about 3.8 s to about 1.4 s.

๐ŸŒWhere it's used

๐Ÿ“Case scenario

A coaching institute's course pages are a client-rendered app, and they barely appear in search results. Moving the course pages to static generation, with revalidation when the fee or dates change, makes their content visible in the HTML. Over the next months the pages start appearing for course searches in the institute's city.

๐Ÿ–ฑ๏ธTry it

List ten pages of a site you know. For each, choose CSR, SSR, static, or static with revalidation, and write one line on why.

โš ๏ธCommon mistakes

๐Ÿ› ๏ธFor your project

In the starter, product pages are built ahead of time (generateStaticParams), while cart and checkout run in the browser. Record why in Project 2.

โœ…Quick check

What is hydration?

Show the answer

JavaScript taking over server-rendered HTML in the browser so the page becomes interactive.

When does static generation with revalidation fit?

Show the answer

For pages that are the same for everyone and change occasionally, such as product pages.

โ† BackFE3
ProLearners Assist