Next.js + Data Fetching Methods
Ketan Mayer-Patel
UNC Department of Computer Science
COMP 426: Modern Web Programming (Fall 2026)
Module 3: Next.js
Lecture 13
In the beginning…
HTML and CSS
It's Alive!
Go Fetch!
App-burger Helper
TypeScript and Vite
React
Next.js – A Complete Framework
App Router
Server vs. Client components
When to fetch?
html
URL
White Screen
Hydration�Not Interactive
^
First�Contentful�Paint
(FCP)
Server renders HTML
Fetch
JS
js
^
Time To�Interactive�(TTI)
Loading Data�Interactive
SSR + Client Data Fetching�Initial Page Load
Fetch
Data
json
Running�Interactive
json
html
URL
White Screen
^
First�Contentful�Paint
(FCP)
Server renders HTML
Fetch
JS
js
^
Time To�Interactive�(TTI)
Running�Interactive
SSR + Server Data Fetching�Initial Page Load
Fetch
Data
Hydration�Not Interactive
Time
Consider a component that displays a list of classes retrieved from an API endpoint.
As a client component
Initial load has empty list, request to API made by client, and list re-rendered client-side when data arrives.
As a server component
Request to API made by server and list rendered to HTML server-side on initial load.
Discuss pros and cons and submit attendance check
When to fetch?
html
URL
White Screen
Hydration�Not Interactive
^
First�Contentful�Paint
(FCP)
Server renders HTML
Fetch
JS
js
^
Time To�Interactive�(TTI)
Loading Data�Interactive
SSR + Client Data Fetching�Initial Page Load
Fetch
Data
json
Running�Interactive
json
html
URL
White Screen
^
First�Contentful�Paint
(FCP)
Server renders HTML
Fetch
JS
js
^
Time To�Interactive�(TTI)
Running�Interactive
SSR + Server Data Fetching�Initial Page Load
Fetch
Data
Hydration�Not Interactive
Time
Client Data Fetching: Has a faster FCP → Better UX.
Server Data Fetching: Has a worse FCP, but better SEO.
SEO only matters if data incorporated into the page is not specific to the user or user's input.
In most cases, we will prefer to stick with client data fetching unless the SEO boost is very important – we prefer to always prioritize FCP.
Anatomy of a client-side component
Anatomy of a server-side component
Issues with client-side fetching
ReactQuery
A04 - Pokedex